NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Dropping Variables


Joined: 17 Jun 2005
Posts: 6
Reply with quote
Hello,

I'm having a bit of debugging trouble. When i enter debug mode then everything is fine, however if i then enter a function, all the variables are dropped, even the ones i have created inside the function, for example

<?php
function doThis($var){
$y = 10;
return $var + $y;
}

$foo = 1;
$result = doThis($foo);

?>

if i don't debug the script then result will be 1
if i debug the script and don't enter the function result will be 1
if i debug the script and enter the function var is undefined and result is undefined and y is undefined but foo is 1.

Hope you can help, i am using phped version 3.3.3 Build 3397
View user's profileFind all posts by RoziSend private message


Joined: 17 Jun 2005
Posts: 6
Reply with quote
Except the $_POST and $_GET they are visible inside the function
View user's profileFind all posts by RoziSend private message


Joined: 17 Jun 2005
Posts: 6
Reply with quote
i say the result will be 1 i mean 11 of course it would be mental if the result was 1
View user's profileFind all posts by RoziSend private message
Veteran

Joined: 24 Jan 2006
Posts: 311
Reply with quote
Ok, lets sort this out. First of all lets make it perfectly clear that the result is 11 - as you mentioned in your last post.
Now:
Quote:
Except the $_POST and $_GET they are visible inside the function

Yes, it makes sense - these are PHP global variables and are visible everywhere as such.
Quote:
if i don't debug the script then result will be 1

Once again - I guess you meant 11 instead of 1 - right?


Quote:
if i debug the script and don't enter the function result will be 1

No, the result will be "undefined" until you enter the function - could you please provide more details related to this use case. What do you mean by not entering the function? Where do you see the result equal to 1? Thanks!

Quote:
if i debug the script and enter the function var is undefined and result is undefined and y is undefined but foo is 1

Again - when exactly does it happen? When you do step into the function or inside the function or as soon as you step outof the function? I think screen shot would be very helpful here - if you could please provide it. Please remember also that $var and $y are local to function scope and will be undefined outside of that function
View user's profileFind all posts by yfaktorSend private message


Joined: 17 Jun 2005
Posts: 6
Reply with quote
when i say "enter the function" i mean enter the function in the debugger not enter the function in the program.

We always enter the function in the program.

In PHPEd i run the debugger by pressing F8 and then i press F8 to run though each line of code. If i do that for each line then it works fine and outputs 11.

However if i press F7 and "enter the function" then $var is undefined even though i passed it $foo (which is 1).

Then i press F8 again and i process this line

Quote:
$y = 10;


however after this $y is still undefined.

So then $result is undefined.

However if i "step over the function" as in process the function but not actually "enter" it in the debugger (press F8 again after $foo = 1; ) Then $result is 11.

Sorry about the confusion with the 1 and 11, thats what happens when i can't debug my code hahahaha Smile
View user's profileFind all posts by RoziSend private message
Veteran

Joined: 24 Jan 2006
Posts: 311
Reply with quote
ok, thanks - the problem might be the old one in 3.3.3 - we'll look into that. However, there is no problem in 4.5 - here is the screen shots:




[/img]
View user's profileFind all posts by yfaktorSend private message


Joined: 17 Jun 2005
Posts: 6
Reply with quote
thanks mate,

it has happenned randomly before, but i just used to restart my computer and it would fix, but today i've tried restarting and reinstalling and it doesn't seem to make any difference.
View user's profileFind all posts by RoziSend private message
Veteran

Joined: 24 Jan 2006
Posts: 311
Reply with quote
Could you try the latest version - you can use the eval to see if it is fixed there.
View user's profileFind all posts by yfaktorSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Rozi,
There are no known issues like this in PhpED 3.3.
If you belive you faced up with a problem, please submit screenshots and detailed description on what you did, what you expected to get and what you actually got.

Thank you.
View user's profileFind all posts by dmitriSend private messageVisit poster's website
Dropping Variables
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic