FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Calling child class from parent class
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Calling child class from parent class [message #181096 is a reply to message #181092] Fri, 12 April 2013 00:11 Go to previous messageGo to previous message
daveh is currently offline  daveh
Messages: 18
Registered: March 2013
Karma:
Junior Member
On Thursday, April 11, 2013 3:48:24 PM UTC-4, da...@allheller.net wrote:
> Is this possible?
>
>
>
> class GNP_DIRECTORY
>
> {
>
> public $m_rules;
>
> public $m_names; //array of GTCM_GNP object names
>
> public $m_cnt;
>
>
>
> public function __construct()
>
> {
>
> $this->m_rules = array();
>
> $this->m_names = array();
>
> $this->m_cnt = 0;
>
> }
>
> public function register($name, $rule, $dat_file, $server, $port)
>
> {
>
> if(in_array($name, $this->m_names))
>
> {
>
> $this->m_rules[$name][] = $rule;
>
> return $this->m_names[$name];
>
> }
>
> $$name = new GTCM_GNP($this);
>
> if(!$$name)
>
> {
>
> return FALSE;
>
> }
>
> $this->m_cnt++;
>
> $this->m_names[] = $name;
>
> $this->m_rules[$name] = array($rule);
>
> return $$name;
>
> }
>
> }
>
> class GTCM_GNP extends GNP_DIRECTORY
>
> {
>
> private $m_server;
>
> private $m_port;
>
> private $m_dat_file;
>
> private $m_socket;
>
> private $m_buffer;
>
> private $m_proc_num;
>
> private $m_open_region;
>
> private $m_cur_region_no;
>
>
>
> public function __construct($name = null, $rule = null, $dat_file, $server,
>
> $port)
>
> {
>
> (initialization code)
>
> }
>
>
>
> public function do_something
>
> {
>
> return $this->variable;
>
> }
>
> }
>
> Basically I need to do: GNP_DIRECTORY[$$names]->do_something();
>
>
>
> or I want to do some method in GTCM_GNP by referring to a specific
>
> GNP_DIRECTORY
>
>
>
> Will this (pseudo)code work or is there a better approach.
>
>
>
> Thanks

Actually I combined the two classes into one (I don't understand why the original programmer did not do that in the first place perhaps because it was written for php version 4.0.6 and also made heavy use of superglobals in his code) And actually the names are not cryptic IF read in the context of what the code does. It actually manipulates a gnp_directory and gtcm_gnp objects. I probably will change the case of the classes however, because "shouting" can be annoying!

Dave
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Calling a php file from another on apache server
Next Topic: Re: eine PHP mit video faehigkeit
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 22:07:44 GMT 2024

Total time taken to generate the page: 0.04032 seconds