Geeky Bird Geeky Bird - 1 year ago 41
jQuery Question

ECHO a <script> via php. I want to know the proper way to do it

I have a url path that will send through this

from a different file.

So the following script tag will catch the user on the website root and forward him to the login page. I can't seem to make this working. I know i am messing the single and double quotes. :(

if (!isset($_SESSION['role']))
echo '<script>window.location.assign("'echo myGlobalFunction();'/onboardingform/core/admin/login.php")</script>';


Answer Source

You're not concatenating the strings properly. Use . operator to concatenate the string like this.


echo '<script>window.location.assign("'. myGlobalFunction().'/onboardingform/core/admin/login.php")</script>';

And there is no need of echo statement inside another echo.