note 50565 added to language.operators.errorcontrol

From: Date: Thu, 03 Mar 2005 16:25:27 +0000
Subject: note 50565 added to language.operators.errorcontrol
Groups: php.notes 
Request: Send a blank email to php-notes+get-85873@lists.php.net to get a copy of this message
If you wish to display some text when an error occurs, echo doesn't work. Use print instead. This is explained on the following link 'What is the difference between echo and print?': http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40 It says "print can be used as part of a more complex expression where echo cannot". Also, you can add multiple code to the result when an error occurs by separating each line with "and". Here is an example: <?php $my_file = @file ('non_existent_file') or print 'File not found.' and $string = ' Honest!' and print $string and $fp = fopen ('error_log.txt', 'wb+') and fwrite($fp, $string) and fclose($fp); ?> A shame you can't use curly brackets above to enclose multiple lines of code, like you can with an if statement or a loop. It could make for a single long line of code. You could always call a function instead. ---- Manual Page -- http://www.php.net/manual/en/language.operators.errorcontrol.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50565 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50565&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50565&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50565&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50565&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50565&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50565&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85873) next »