On: December 8, 2012 Posted in Uncategorized Comments: 4 Views: 124 Difference b/ween PHP 4 and PHP 5??? Education Questionsinterview-questions
unlike in PHP 4, you can pass objects by reference in PHP 5
example-
marks = ‘backlog’;
$Anup = $Asutosh; //Pass it
$Anup->marks = ‘pass’;
//now print marks of Asutosh, it will give output as ‘pass’ even if we had assigned backlogs 1st to Asutosh.
//So enter
echo $Asutosh->marks;
?>
output will be ‘pass’
try it. Copy and paste the code at http://www.codetable.org … n use php from the options
In PHP 5 u can pass objects by reference…
marks = ‘backlog’;
$Anup = $Asutosh;
$Anup->marks = ‘pass’;
//now print marks of Asutosh, it will give output as ‘pass’ even if we had assigned backlog 1st to Asutosh.
//So enter Asutosh’s marks to be printed
echo $Asutosh->marks;
?>
Run this code at http://www.codetable.org and u will get outpust as ‘pass’
In PHP 5 u can pass objects by reference…
marks = ‘backlog’;
$Anup = $Asutosh;
$Anup->marks = ‘pass’;
//now print marks of Asutosh, it will give output as ‘pass’ even if we had assigned backlog 1st to Asutosh.
//So enter Asutosh’s marks to be printed
echo $Asutosh->marks;
?>
Run this code at http://www.codetable.org and u will get outpust as ‘pass’
Asutosh Panda
I have left the PHP opening tag ” <?php " by mistake. Do add it where ur file begins