Jump to content

passing variable between two functions


MDanz

Recommended Posts

i have two functions.  In function two it has $id=9.  how do i get function one to echo $id?

 

how do i adjust the below example to accomplish this?


$newdb = new Database();

class Database
{

function one()
{
$newdb->two();
echo $id;
}

function two() 
{
$id = 9
return $id;
}

}

Link to comment
https://forums.phpfreaks.com/topic/228946-passing-variable-between-two-functions/
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.