Jump to content

Simple Variable reference Question


milesperhour1086

Recommended Posts

When creating a page in PHP, if I have the following:

[code]
    php:$thisVar = $myArray[2];
    ..
    ..
    ..
    ..
    $myArray = array(1,43,64,44);
    ?>
[/code]


Will thisVar be assigned 64 or will it be null because when we assigned thisVar, myArray did not exist yet?? I am trying to work with dreamWeaver templates and php and this is one of the things I need to figure out but I Don't have webspace to test it out on yet. Thanks
Link to comment
https://forums.phpfreaks.com/topic/5613-simple-variable-reference-question/
Share on other sites

[!--quoteo(post=357686:date=Mar 23 2006, 05:51 PM:name=milesperhour1086)--][div class=\'quotetop\']QUOTE(milesperhour1086 @ Mar 23 2006, 05:51 PM) [snapback]357686[/snapback][/div][div class=\'quotemain\'][!--quotec--]
When creating a page in PHP, if I have the following:

[code]
    php:$thisVar = $myArray[2];
    ..
    ..
    ..
    ..
    $myArray = array(1,43,64,44);
    ?>
[/code]
Will thisVar be assigned 64 or will it be null because when we assigned thisVar, myArray did not exist yet?? I am trying to work with dreamWeaver templates and php and this is one of the things I need to figure out but I Don't have webspace to test it out on yet. Thanks
[/quote]

it'll be null if you do it in this order. scripting languages do everything in line order, the only exceptions being things such as functions, loops (while, for, foreach, etc). your opening php tag must be <?php too, not php:
[!--quoteo(post=357689:date=Mar 23 2006, 09:59 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Mar 23 2006, 09:59 AM) [snapback]357689[/snapback][/div][div class=\'quotemain\'][!--quotec--]
it'll be null if you do it in this order. scripting languages do everything in line order, the only exceptions being things such as functions, loops (while, for, foreach, etc). your opening php tag must be <?php too, not php:
[/quote]
thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.