It also works for me Take a look at a live example of your code here However, there are a few things you should change about your class First, Garvey does make a good point that you should not be using var That's the older PHP4, less OOP conscious version. Rather declare each variable public or private In fact, you should declare each function public or private too Generally, most classes have private variables, since you usually only want to change the variables in specific ways. To achieve this control you usually set several public methods to allow client functions to interact with your class only in restricted predetermined ways If you have a getter you'd probably want a setter since these are usually used with private variables, like I described above A final note is that functions named get usually return a value.
If you want to display a value, it is customary to use a name like display_path or show_path :? Php class PageClass { private $absolute_path = NULL; public function set_absolute_path($path) { $this->absolute_path = $path; } public function display_absolute_path() { echo $this->absolute_path; } } $page = new PageClass(); $page->set_absolute_path("http://localhost:8888/smile2/organic/"); $page->display_absolute_path(); // The above outputs: http://localhost:8888/smile2/organic/ // Your variable is now safe from meddling. // This: // echo $this->absolute_path; // Will not work.It will create an error like: // Fatal error: Cannot access private property PageClass::$absolute_path on ...? Live Example Here There's a section on classes and objects in the online PHP reference.
It also works for me. Take a look at a live example of your code here. However, there are a few things you should change about your class.
First, Garvey does make a good point that you should not be using var. That's the older PHP4, less OOP conscious version. Rather declare each variable public or private.In fact, you should declare each function public or private too.
Generally, most classes have private variables, since you usually only want to change the variables in specific ways. To achieve this control you usually set several public methods to allow client functions to interact with your class only in restricted predetermined ways. If you have a getter, you'd probably want a setter, since these are usually used with private variables, like I described above.
A final note is that functions named get usually return a value. If you want to display a value, it is customary to use a name like display_path or show_path: absolute_path = $path; } public function display_absolute_path() { echo $this->absolute_path; } } $page = new PageClass(); $page->set_absolute_path("localhost:8888/smile2/organic/"" rel="nofollow">localhost:8888/smile2/organic/"); $page->display_absolute_path(); // The above outputs: localhost:8888/smile2/organic/ // Your variable is now safe from meddling. // This: // echo $this->absolute_path; // Will not work.
It will create an error like: // Fatal error: Cannot access private property PageClass::$absolute_path on ...?> Live Example Here There's a section on classes and objects in the online PHP reference.
Class PageClass { public $absolute_path = NULL; function get_absolute_path(){ $url = $this->absolute_path; return $url; } } $page = new PageClass(); $page->absolute_path = "localhost:8888/smile2/organic/"; echo $page->get_absolute_path().
Works fine for me. Have you checked that the script and esp. The code in question is executed at all?E.g.
Add some unconditional debug-output to the script. Or install a debugger like XDebug to step through the code and inspect variables. Absolute_path; echo "debug: "; var_dump($url); echo $url; } } $page = new PageClass(); $page->absolute_path = "localhost:8888/smile2/organic/"; echo "debug: page->get_absolute_path\n"; $page->get_absolute_path().
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.