note 114821 added to functions.user-defined

From: Date: Wed, 09 Apr 2014 13:56:15 +0000
Subject: note 114821 added to functions.user-defined
Groups: php.notes 
Request: Send a blank email to php-notes+get-199236@lists.php.net to get a copy of this message
<?php // first run (function doesn't exist) $myfunc_exists; if (! $myfunc_exists) { function myfunc() { echo ('myfunc ran definition #1<br>'); } $myfunc_exists = true; } myfunc(); // echoes 'myfunc ran definition #1<br>' // second run (function already exists, so won't be redefined and won't cause error) // e.g. if the file containing the function got #included twice (it does happen) $myfunc_exists; if (! $myfunc_exists) { function myfunc() { echo ('myfunc ran definition #2<br>'); } $myfunc_exists = true; } myfunc(); // still echoes 'myfunc ran definition #1<br>' (not #2) ?> ---- Server IP: 72.52.91.14 Probable Submitter: 211.28.52.196 ---- Manual Page -- http://php.net/manual/en/functions.user-defined.php Edit -- https://master.php.net/note/edit/114821 Del: integrated -- https://master.php.net/note/delete/114821/integrated Del: useless -- https://master.php.net/note/delete/114821/useless Del: bad code -- https://master.php.net/note/delete/114821/bad+code Del: spam -- https://master.php.net/note/delete/114821/spam Del: non-english -- https://master.php.net/note/delete/114821/non-english Del: in docs -- https://master.php.net/note/delete/114821/in+docs Del: other reasons-- https://master.php.net/note/delete/114821 Reject -- https://master.php.net/note/reject/114821 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#199236) next »