PHP Learning Diary (a)--class, function usage, PHP Diary
One, Custom function
function Add ($a,$b) { $c=$a+$b; Echo ' Add test: '; Echo $c ; return $c ;} Add (+);
Output Result:
Add Test:3
Second, call the function inside the class
1, double colon::, without instantiation, direct class name call
class test{ publicfunction Add ($a,$b) { $c= $a+$b; Echo ' Class test: '; Echo $c ; return $c ; }} Test:: Add (+);
2,-> the object used after instantiation
class test{ publicfunction Add ($a,$b) { $c=$a+$b; Echo ' Class test: '; Echo $c ; return $c ; }} $object=new test (); $object->add (1,3);
http://www.bkjia.com/PHPjc/1059466.html www.bkjia.com true http://www.bkjia.com/PHPjc/1059466.html techarticle PHP Learning Diary (a)-the use of classes, functions, PHP Diary one, the custom functions function add ($a, $b) {$c = $a + $b; Echo ' Add Test: '; echo $c; return $c;} Add (+); Output ...