note 68128 added to language.basic-syntax.comments

From: Date: Fri, 14 Jul 2006 05:28:39 +0000
Subject: note 68128 added to language.basic-syntax.comments
Groups: php.notes 
Request: Send a blank email to php-notes+get-114773@lists.php.net to get a copy of this message
a trick I have used in all languages to temporarily block out large sections (usually for test/debug/new-feature purposes), is to set (or define) a var at the top, and use that to conditionally comment the blocks; an added benefit over if(0) (samuli's comment from nov'05) is that u can have several versions or tests running at once, and u dont require cleanup later if u want to keep the blocks in: just reset the var. personally, I use this more to conditionally include code for new feature testing, than to block it out,,,, but hey, to each their own :) this is also the only safe way I know of to easily nest comments in any language, and great for multi-file use, if the conditional variables are placed in an include :) for example, placed at top of file: <?php $ver3 = TRUE; $debug2 = FALSE; ?> and then deeper inside the file: <?php if ($ver3) { print("This code is included since we are testing version 3"); } ?> <?php if ($debug2) { print("This code is 'commented' out"); } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 74.12.104.231 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.basic-syntax.comments.php Edit -- http://master.php.net/note/edit/68128 Del: integrated -- http://master.php.net/note/delete/68128/integrated Del: useless -- http://master.php.net/note/delete/68128/useless Del: bad code -- http://master.php.net/note/delete/68128/bad+code Del: spam -- http://master.php.net/note/delete/68128/spam Del: non-english -- http://master.php.net/note/delete/68128/non-english Del: in docs -- http://master.php.net/note/delete/68128/in+docs Del: other reasons-- http://master.php.net/note/delete/68128 Reject -- http://master.php.net/note/reject/68128 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114773) next »