Debugging value returned by class function call

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Debugging value returned by class function call

Post by anjanesh »

Im debugging one class and was using die($obj->varORmethod) to get the run-time value.

Code: Select all

include_once('cls.class.php');
$obj = new cls();
echo $obj->foo(); die(); # Works. Outputs correct value
but if I change the last line to die($obj->foo());, it returns blank.

$cls->foo() returns an integer.

How is this possible ?

Using PHP 5.1.4

Thanks
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

I am not 100% sure but I think its because it already killed the PHP Script. This might work:

Code: Select all

include_once('cls.class.php'); 
$obj = new cls(); 
$die = $obj->foo(); 
die($die);
Post Reply