php variable scope in oop

Posted by mr o on Stack Overflow See other posts from Stack Overflow or by mr o
Published on 2010-03-13T19:40:14Z Indexed on 2010/03/13 19:45 UTC
Read the original article Hit count: 567

Filed under:

Hi, I wonder if anyone can help out here, I'm trying to understand how use an objects properties across multiple non class pages,but I can't seem to be able to get my head around everything i have tried so far.

For example a class called person;

class person {
 static $name;     

but i have a number of different regular pages that want to utilize $name across the board.

I have trying things like this;


include "person.php";
$names = new Person();

echo person::$name;


include "person.php";
echo person::$name;

I can work with classes to the extent I'm OK as long as I am creating new instances every page, but how can make the properties of one object available to all, like a shared variable ?


© Stack Overflow or respective owner

Related posts about php

Related posts about oop