www.webdeveloper.com
Results 1 to 2 of 2

Thread: php request and config

  1. #1
    Join Date
    Apr 2005
    Posts
    210

    php request and config

    This piece of code is copied from a formal php pack - I changed class names:
    Code:
    class MyBase extends MyTop {	
    	public function searching() 
    	{   
    		.........
    		$this->data['boxes'] = array();
    		
    		if (isset($this->request->post['real_box'])) {
    			$this->data['boxes'] = $this->request->post['real_box'];
    		} elseif ($this->config->get('real_box')) { 
    			$this->data['boxes'] = $this->config->get('real_box');
    		}
    		........
    	}
    }
    I don't understand this 2 line:

    $this->request->post['real_box']
    $this->config->get('real_box')


    request and config are neither function or variable of this class or parent class.

    Are they global function or variable?
    Or they are fix php methods?
    what are they possibly?

    I am a C++ programmer and know little php, I can't get answer from google.

    Thanks.


    .

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,614
    Does the class definition include any __get() and/or __set() methods? (Note that those two method names begin with double underscores.) If so, then it may be using those "magic" methods to get/set one or more class variables.

    If not, then it may be assuming that unspecified object variables are possibly being set (not very robust coding, IMO, but allowed), e.g.:
    PHP Code:
    <pre><?php

    class Foo
    {
        public function 
    bar()
        {
            if(isset(
    $this->unnamed)) {
                return 
    $this->unnamed;
            }
            return 
    null;
        }
    }

    $foo = new Foo();
    $test $foo->bar();
    var_dump($test);
    $foo->unnamed "This is a test.";
    $test $foo->bar();
    var_dump($test);
    ?></pre>
    Output:
    Code:
    NULL
    string(15) "This is a test."
    Last edited by NogDog; 05-06-2012 at 12:55 PM.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles