Jump to content


Photo

Simple Variable reference Question


  • Please log in to reply
2 replies to this topic

#1 milesperhour1086

milesperhour1086
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 23 March 2006 - 05:51 PM

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

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


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
Micah[br] --PHP Newbie

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 23 March 2006 - 05:59 PM

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

    php:$thisVar = $myArray[2];
    ..
    ..
    ..
    ..
    $myArray = array(1,43,64,44);
    ?>
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:
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 milesperhour1086

milesperhour1086
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 23 March 2006 - 06:00 PM

[!--quoteo(post=357689:date=Mar 23 2006, 09:59 AM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Mar 23 2006, 09:59 AM) View Post[/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
Micah[br] --PHP Newbie




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users