'hello'; $obj->foo = new stdClass(); $obj->foo->bar = 123; echo "Value is $obj->some"; //Object of class stdClass could not be converted to string in echo "Value is $obj->foo->bar"; //Value is 123 echo "Value is {$obj->foo->bar}"; //Same for array $ar = array('some' => 'var'); echo "Value is $ar['some']"; //syntax error echo "Value is {$ar['some']}"; //Value is var
file that is automatically parsed before the main file. The file is included as if it was called with the require()function, so include_path is used. The special value none disables auto-prepending.
file that is automatically parsed before the main file. The file is included as if it was called with the require()function, so include_path is used. The special value none disables auto-prepending. Great
'bar' => 1987, 'wee' => 'ugh' ); // not like that - works only for number indexed arrays without gaps ! $random = $data[rand(0, count($data) - 1)]; // or that way - array_rand returns key, not value! $random = array_rand($data); // that way - works always $random = $data[array_rand($data)];
case 'Joey': case 'Rachel': case 'Ross': /* ... */ echo 'Best comedy show ever'; break; case 'Barney'; case 'Ted'; /* ... */ echo 'Like a copy of best show ever, but still good one'; break; default: echo 'Maybe another good show'; }
'Rachel', 'Ross', 'Phoebe', 'Monica', 'Chandler'))) ) { echo 'Best comedy show ever'; } else if (in_array($person, array('Barney', 'Ted', 'Lily', 'Marshal', 'Robin'))) ) { echo 'Like a copy of best comedy show ever, but still good one'; } else { echo 'Maybe another good show'; }
$i++) { $var++; echo $var, ' '; } //output? //b c d e f g h i j k l m n o p q r s t u v w x y z aa ab ac ad ae af ag ah ai aj ak al am an ao ap aq ar as at au av aw ax ay az ba bb bc bd be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv bw bx by bz ca cb cc cd ce cf cg ch ci cj ck cl cm cn co cp cq cr cs ct cu cv cw cx cy cz da db dc dd de df dg dh di dj dk dl dm dn do dp dq dr ds dt du dv dw dx dy dz ea eb ec ed ee ef eg eh ei ej ek el em en eo ep eq er es et eu