how to output php in a javascript file .js

sapo

Power Member
Joined
Feb 25, 2008
Messages
510
Reaction score
286
im tyring to add my php varible to an url

for example.

php varible is

Code:
<?php echo 'hello!'; ?>

and my javscript is

Code:
var = 'http://site.com/login/?


i need to parse the php into the url like this

Code:
var = 'http://site.com/login/?[php varible]'

I just cant figure it out this is what I came up with but you guessed it doesnt work

Code:
var = url = 'http://site.com/' + '.document.write("<?php echo 'hello!'; ?>")';'


any help will be greatly apperciated. reps and thanked
 
Last edited:
Try something like this.
Code:
var = 'http://site.com/login/?<?php echo $a_php_variable; ?>'

I assume that your page is a .php page.

D.
 
Try something like this.
Code:
var = 'http://site.com/login/?<?php echo $a_php_variable; ?>'

I assume that your page is a .php page.

D.

its a .js file. I am trying to call the php variable form inside a .js file
 
LOL man IM a idiot. Thanks. i as trying to do it in reverse dont know lol. been trying to figure this out for hours non stop and finally took a step back drank tall can and bam came back and bam it clicked.
 
The hardest thing is to find a little stupid mistake. I know I've been coding for many, many years.

D.
 
Back
Top