Ask a Question related to PHP Development, Design and Development.
-
Ed Koren #1
new to php classes
Hi everyone,
I am new to using classes in PHP development. Can someone tell me if
it's possible to use a class inside a class. I am developing a class
that will handle all aspects of MLS listings (real estate). Yet, I want
to use a PEAR class to extract images from .tar archives. Can I simply
include this PEAR class into my own class? Or is this bad practice,
perhaps?
Thanks in advance,
Ed
Ed Koren Guest
-
two classes
how can I call class b method b, from class a method a ? -
Classes
do you get an error-message? which? maybe you use var $id = array(); instead of var $id; ciao SVEN Patrik Fomin wrote: -
AS2.0 & inner classes
Greetings... Does ActionScript 2.0 allow the creation of inner classes? Thanks. Respectfully, ASP -
First Go at Classes
So, here I am, I've been programming PHP for 6 years, and have never gotten into classes. Well, I finally decided to take the plunge, and here's my... -
ASP Classes vs COM
For the majority of my work, I just use plain ASP. On the rare occasion that I am doing something intensive that does require user interaction I... -
Janwillem Borleffs #2
Re: new to php classes
Ed Koren wrote:
Shure you can this, as long as you call the class static or use an object> I am new to using classes in PHP development. Can someone tell me if
> it's possible to use a class inside a class. I am developing a class
> that will handle all aspects of MLS listings (real estate). Yet, I
> want to use a PEAR class to extract images from .tar archives. Can I
> simply include this PEAR class into my own class? Or is this bad
> practice, perhaps?
>
instance to reference it:
class SomeClass {
function sayHello () {
print "hello";
}
}
// Static call to SomeClass
class StaticCaller {
function callSayHello () {
SomeClass::sayHello();
}
}
// Create object instance and use that
class InstanceCaller {
function callSayHello () {
$someclass = new SomeClass;
$someclass->sayHello();
}
}
HTH;
JW
Janwillem Borleffs Guest
-
Chris Hope #3
Re: new to php classes
Ed Koren wrote:
You could be wanting to do one of two things.> I am new to using classes in PHP development.**Can*someone*tell*me*if
> it's possible to use a class inside a class.**I*am*developing*a*class
> that will handle all aspects of MLS listings (real estate).**Yet,*I*want
> to use a PEAR class to extract images from .tar archives.**Can*I*simply
> include this PEAR class into my own class?**Or*is*this*bad*practice,
> perhaps?
The first is to inherit/derive a new class from an existing one eg:
class foo {
var $somevar;
function doSomething() {
}
}
class bar extends foo {
function doSomethingElse();
}
$bar = new bar();
$bar->doSomething(); // inherited method call
$bar->somevar = 1; // setting value of inherited property
$bar->soSomethingElse(); // calling method from new class
The second possibility (which I think is probably more along the lines of
what you are wanting to do) is to just have a class property which is
another class object eg:
class foo {
function doSomething() {
}
...
}
class bar {
var $foo;
function bar() {
$this->foo = new foo();
}
...
}
$bar = new bar();
$bar->foo->doSomething();
--
Chris Hope - The Electric Toolbox - [url]http://www.electrictoolbox.com/[/url]
Chris Hope Guest



Reply With Quote

