PHP Varialbes into URL onload<

windows

Guest
I am using the following code where i need to substitute the variables with php $variable1 and $variable2:

<body onload="parent.frames[0].location=('https://website.com/search/stock=VARIABLE1&exchange=VARIABLE2');">

How can i concatenate this so that the variables fill-in where indicated and then retrieve the URL.

Thank you.you need to stay in php mode to do it.


<?php
$VARIABLE1 = "something";
$VARIABLE2 = "somethingelse";
echo" <body onload=\"parent.frames[0].location=('https://website.com/search/stock=".$VARIABLE1."&exchange=".$VARIABLE2."');\">
?>or

<body onload="parent.frames[0].location=('https://website.com/search/stock=<?php echo $variable1; ?>&exchange=<?php echo $variable2; ?>');">Thank you both... exactly what i needed.or

<body onload="parent.frames[0].location=('https://website.com/search/stock=<?=$variable1?>&exchange=<?=$variable2?>');">

<?=$variable?> is short for <? php echo $variable; ?> ;)<?= is short syntax if your host doesn't have that enabled it will not work.

and it is short for <? echo NOT <?php echo

the = sign is echoOriginally posted by scoutt
and it is short for <? echo NOT <?php echo

the = sign is echo

<?php or <? is the same thing hence <?= is the same as <?php echo or <? echono,

<?php is NOT the same as <? (yes it has the same ***ntion, open for php, but they are different.)

<? is short_open_tag


; Allow the <? tag. Otherwise, only <?php and <script> tags are recognized.
short_open_tag = On

if that is off <? will not work, hence they are not the same. the equal sign is the short for echo.

<!-- m --><a class="postlink" href="http://www.php.net/echo">http://www.php.net/echo</a><!-- m -->

echo() also has a shortcut syntax, where you can immediately follow the opening tag with an equals sign. This short syntax only works with the short_open_tag configuration setting enabled.
 
Back
Top