JavaScript with Php.
Moderator: General Moderators
JavaScript with Php.
Hey.
I was wondering if it's prossible to give a JS variable the value of a php variable(which I'm sure there is a way), and such related?
Basicly I devote this topic to using JavaScript and PHP. So good things.
I was wondering if it's prossible to give a JS variable the value of a php variable(which I'm sure there is a way), and such related?
Basicly I devote this topic to using JavaScript and PHP. So good things.
Code: Select all
var thisValue = '<?php echo $thisValue; ?>';
cool that simple eh. Yeah I got a little discouraged when I tried.
and
but yeah I get it now.
And that ain't all. As I said I devote this topic to all things javascript and php, when used together that is.
Code: Select all
var MyVar = </script><? $myvar ?><script>;Code: Select all
var MyVar = <? $myvar ?>;And that ain't all. As I said I devote this topic to all things javascript and php, when used together that is.
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
Code: Select all
<? $myvar ?>;no short tags.
just my opinion though.
plenty have threads have discussed it, i wont go into it in this one.
just a suggestion
This is a little quicker than having to type 'echo'
Code: Select all
var thisValue = '<?=$thisValue?>';Also generally considered bad practiceWard wrote:This is a little quicker than having to type 'echo'
Code: Select all
var thisValue = '<?=$thisValue?>';
-
Charles256
- DevNet Resident
- Posts: 1375
- Joined: Fri Sep 16, 2005 9:06 pm