• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
question about method chaining

i got a "syntax error, unexpected T_OBJECT_OPERATOR" error, and i searched the forum, now i know it's because the php4 not allow method chaining. i shouldn't use the syntax such as
in my php4 web server.
instead of the upper one ,i should use
but i searched the source of codeigniter , i found lots of statement such as:
if ($this->CI->db->cachedir == '')
        return $this->CI->db->cache_off();
    $path = $this->CI->db->cachedir;
    if ($this->CI->db->db_debug)
        return $this->CI->db->display_error('db_invalid_cache_path');
is this method chaining? i donno whecher it can run property in php4 server. anybody know this? great thanks.

That code works fine under PHP4. Were you missing a semi-colon at the end?

Method chaining (PHP5 only) is a very convenient shortcut which lets you access multiple methods on the same object in a single line of code:


where(), orderby(), and limit() are all methods of $this->db (an instance of the Database class).

The CodeIgniter code you posted is not method chaining. It's just accessing a single property or method on objects attached to other objects.

thank you coolfactor, you are really cool!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.