<?php function Prod($prod) { if (strlen($prod['img']) > 0) { echo 'Image with $prod["img"] = '.$prod['img']."\n"; } else { echo 'Image without $prod["img"]'."\n"; } echo "\n";} Prod(array('img' => 'test'));Prod(array('img' => ''));Prod('test');
Standard input is empty
Image with $prod["img"] = test Image without $prod["img"] Image with $prod["img"] = t
PHP Warning: Illegal string offset 'img' in /home/fyajjb/prog.php on line 4 PHP Warning: Illegal string offset 'img' in /home/fyajjb/prog.php on line 5
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!