[ create a new paste ] login | about

Link: http://codepad.org/GqOe7M4v    [ raw code | output | fork ]

php.programmer - PHP, pasted on Apr 24:
<?php

// sample code for showing how type hinting is used in php

class a
{
   public function __construct(b $b)
   {
     echo $b->v;
   }
}
class b
{
  public $v;
  function __construct($val)
  {
    $this->v = $val;
  }
}
$objb = new b('PHP is best');
$obj = new a($objb);
?>


Output:
1
PHP is best


Create a new paste based on this one


Comments: