} try { something(); } catch (A $a1) { } catch (C $c2) { } catch (B $b3) { } try { something(); } catch (B $b1) { } catch (C $c2) { } catch (A $a3) { } try { something(); } catch (B $b1) { } catch (A $a2) { } catch (C $c3) { } try { something(); } catch (C $c1) { } catch (B $b2) { } catch (A $a3) { } try { something(); } catch (C $c1) { } catch (A $a2) { } catch (B $b3) { }
<?php $db = something(); $db['something'] = "Piyush"; print_r($db); function something() { $obj = array(); $obj['name'] = 'Piyush'; return $obj; }
<?php /** * Function calls arguments indentation */ doSomething($p1, $p2); doSomething($p1, $p2); doSomething($p1, $p2); // NOK doSomething($p1, something($p1, $p2, $p3, $p4)); doSomething($p1, array($p1, $p2), $p2); doSomething($p1, $p2); // OK doSomething($p1, $p2); doSomething(anotherThing($p1, $p2, $p2)); /** * Method declaration argument indentation */ function f($p1, $p2) { } function g($p1, $p2) { } function h($p1, $p2) { } function j($p1, $p2) { } function k($p1, $p2)
public function foo() { $y = something(); }
<?php // What is the result of the following code snippet? $array = array('a' => 'John', 'b' => 'Coggeshall', 'c' => array('d' => 'John', 'e' => 'Smith')); function something($array) { extract($array); return $c['e']; } print something($array); /* 1) Smith OK 2) A PHP Warning 3) Coggeshall 4) NULL 5) Array */