You are here: Re: How to address a method outof another method from a different class « All PHP « IT news, forums, messages
Re: How to address a method outof another method from a different class

Posted by Rik on 10/01/95 11:56

T. Wintershoven wrote:
> English version:
>
> When i want to address a method in an object from a method that is
> within another object i get an error message that sais that the
> object doesn't exist.

It's a scope issue.

> The code below doesn't work because i use a function.
> require_once("clsTestObject.php");
> $objTestObject = new clsTestObject;
>
> do_test_var();
>
> function do_test_var()
> {

You either need:
global $objTestObject;

> $objTestObject->ShowTestVar();
> $objTestObject->SetTestVar();
> $objTestObject->ShowTestVar();

OR:
$GLOBALS['objTestObject']->ShowTestVar();
$GLOBALS['objTestObject']->SetTestVar();
$GLOBALS['objTestObject']->ShowTestVar();

> }

Check: http://nl3.php.net/manual/en/language.variables.scope.php

> Bij voorbaat dank

Graag gedaan,
--
Rik Wasmus

 

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

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