You are here: Re: Problem with classes « PHP Programming Language « IT news, forums, messages
Re: Problem with classes

Posted by ZeldorBlat on 09/20/06 20:36

Jag wrote:
> Hello there!
> At the beginning, I'm apologize
> for my weak english skills.
> I got a problem with the class
> which I include from the other
> file. It's hard to me to explain
> it clearly, so I just give you
> files:
>
> index.php:
>
> <?php
> include("someclass.inc.php");
> $c=new classA();
> $c->SayHallo();
> include("another.php");
> ?>
>
> comeclass.inc.php:
>
> <?php
> class classA()
> {
> function __construct()
> {
> echo 'Constructing...';
> }
> function SayHello()
> {
> echo "Hello, cruel world.";
> }
> }
> ?>
>
> another.php:
>
> <?php
>
> First try:
> $c->SayHello(); // error :/
>
> Second try:
> $c=new classA(); // ALMOST works. It
> $c->SayHallo(); // defines second
> // instance of the
> // class ClassA.
> // Unfortunetly, I
> // need to work on
> // the same instance.
> ?>
>
> Hope somebody helps me - how to define
> class and work with one and the same
> instance?
>
> --
> best regards
> Jag

If you are, in fact, including another.php inside index.php where you
say you are, then that shouldn't be a problem. What error are you
getting? Could it be that the method of the class is called "SayHello"
and you're trying to call "SayHallo" ?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация