Page 1 of 1
php object
Posted: Wed Mar 26, 2008 10:49 pm
by jamesalexander
good day,
i am new to php about a month old programming this kind of language and i still unable to grasp the object programming style that i used to see on tutorials and books
can anybody shed a light on this one
thank u
Re: php object
Posted: Wed Mar 26, 2008 11:53 pm
by Christopher
The simplest way to think about an object is as data structure with its own set of local functions that can operate on that data. The 'class' construct creates a namespace for the variables and functions in it. There are obviously many more interesting things you can do once you start coding classes and creating objects from them, but that modularity is the basic benefit.
Re: php object
Posted: Thu Mar 27, 2008 7:57 pm
by jamesalexander
gud day again...
tnx ... i run to a (public, var, $this) thing is this any related to the PHP functions ?
what is the difference if i type include and the include once does it mean that i can only use the
"whatever inside that function once" ?
thanks for bearing with me.............
Re: php object
Posted: Thu Mar 27, 2008 9:47 pm
by Christopher
jamesalexander wrote:tnx ... i run to a (public, var, $this) thing is this any related to the PHP functions ?
If you have PHP4 use
var $foo;. If you have PHP then private, protected, public control the what can access the property. There is an example in the manual.
jamesalexander wrote:what is the difference if i type include and the include once does it mean that i can only use the
"whatever inside that function once" ?
Try this:
File: inc.php
Code: Select all
<?php
echo "The file was included. <br/>";
?>
File: test1.php
Code: Select all
<?php
include 'inc.php';
include 'inc.php';
?>
File: test2.php
Code: Select all
<?php
include_once 'inc.php';
include_once 'inc.php';
?>
Re: php object
Posted: Mon Mar 31, 2008 7:22 pm
by jamesalexander
tnk u for the reply guys........
Re: php object
Posted: Mon Mar 31, 2008 9:16 pm
by Chris Corbyn
Please stop using AOL speak in our forums. People who are not primarily English speaking really struggle with it. Words like "u", "r", "4", "2" etc should be replaced their proper words "you", "are", "for", "two".