Possible Duplicate:
PHP method chaining?
I want to use functions combined, like:
select("SELECT * FROM users").where("user=l0 ").join(" . . . "); How to define this in php?
Possible Duplicate:
PHP method chaining?
I want to use functions combined, like:
select("SELECT * FROM users").where("user=l0 ").join(" . . . "); How to define this in php?
function select(){ .... return new myType; } class myType { function where(){ ... return $this; } function join(){ ... return $this; } } Demo: http://codepad.org/pyrIEW0t
Remember to use -> instead of . in PHP.
This is an example of PHP function chaining.
The function returns a string and you concatenate the return values of multiple functions.
function select($input) { //process $input return $output; } function where($input) { //process $input return $output; } In your php you can call these functions and get the returning result concatenated.