The problem is coming again. What are the experts ;? Phperror_reporting (E_ALL | E_STRICT); classmycls {& nbsp; private $ p1; & nbsp; ** the overloaded data is stored here * & nbsp; private $ dataarray (); & nbsp; & nbs problem again, big bull
Error_reporting (E_ALL | E_STRICT );
Class mycls {
Private $ p = 1;
/** Store the overloaded data here */
Private $ data = array ();
Function func ()
{
Echo "none static ";
}
/* Public function _ set ($ name, $ value)
{
Echo "Setting '$ name' to' $ value'
\ N ";
$ This-> $ name = $ value;
}*/
Public function _ get ($ name)
{
Echo "Getting '$ name'
\ N ";
Return $ this-> $ name;
}
}
$ My = new mycls;
$ My-> a = 10 ;//
Echo $ my->;
?>
------ Solution --------------------
No problem
------ Solution --------------------
You have $ my-> a = 10;
Of course, it won't call _ get.
------ Solution --------------------
You can write it in this way.
PHP code
Error_reporting (E_ALL | E_STRICT); class mycls {private $ p = 1;/** the overloaded data is saved here */private $ data = array (); function func () {echo "none static";} public function _ set ($ name, $ value) {echo "Setting '$ name' to '$ value'
\ N "; $ this-> data [$ name] = $ value;} public function _ get ($ name) {echo" Getting '$ name'
\ N "; return $ this-> data [$ name] ;}}$ my = new mycls; $ my-> a = 10; // echo $ my->;
------ Solution --------------------
Erer
------ Solution --------------------
$ My = new mycls;
Echo $ my-> a; // direct output will be called.
If no echo statement is available and the value is assigned directly, _ set is called.
But your code is logged out.
------ Solution --------------------
Discussion
Reference:
Reference:
You can write it in this way.
PHP code
Error_reporting (E_ALL | E_STRICT );
Class mycls {
Private $ p = 1;
/** Store the overloaded data here */
Private $ data = array ();
Function func ()
{
Echo "none sta ......