Some principles php class knowledge drip --- class inherits

  • Completely rewritten

<?php

class coach

{

   public function __construct()

   {

     echo "Welcome to the North Wu Tang training ~ ~" ;

   }

}

 

 

class cj extends coach

{

   public function __construct($name)

   {

     echo "Oh ~ Long time no see" $ name.;

   }

}

$ Cj = new cj ( 'cauldron D');

?>

 

After instantiating output:

Oh ~ Long time no see Ding cauldron

  • Enhancements based on the original (key expression: parent :: method name)
? <PHP 
class Coach
{
public function __construct ()
{
echo "Welcome to the North Wu Tang training ~ ~";
}
}
class the extends Coach CJ
{
public function __construct ()
{
parent :: __ Construct ();
echo "practice today point ? What strength training still standing or ground fighting techniques ";
}
}
$ = new new CJ CJ ();
>?

output:

Welcome to the Northern Wu Tang training ~ ~ practice something today? Strength training is still standing or ground fighting techniques

Guess you like

Origin www.cnblogs.com/saintdingspage/p/10958647.html