Jump to content

variable scoope


hassank1

Recommended Posts

I've a problem ..

 

if I type something like :

 

<?php

$x=353;

.

.

.

?>

 

<html>

.

.

<?php

echo $x;

?>

.

.

.

</html>

 

--

 

the problem is that sometimes .. when I use html between php tags .. the variable still set and has its value (which suppose to be the case !) .. so when I echo x later. I got 353 .. however in some cases when I define x .. and then I close and open php tags later .. I can't get the value of x as if it's not declared b4!

Link to comment
https://forums.phpfreaks.com/topic/104852-variable-scoope/
Share on other sites

You would need to post specific code that has the problem.

 

Unless register_globals are on and you have a post/get/cookie/session variable with the same name as your program variable, the only thing that will change the value in a variable is YOUR CODE. Programs only do what the code says. A common problem is using one equal sign = (an assignment operator) in a comparison instead of two equal signs == (a comparison operator), which is why you would need to post the code that is having the problem for anyone in a Forum to be able to see and help you with the problem.

Link to comment
https://forums.phpfreaks.com/topic/104852-variable-scoope/#findComment-536673
Share on other sites

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.