note 97013 added to language.operators.comparison

From: Date: Sun, 28 Mar 2010 17:34:58 +0000
Subject: note 97013 added to language.operators.comparison
Groups: php.notes 
Request: Send a blank email to php-notes+get-167462@lists.php.net to get a copy of this message
A good use of the ternary if is to quickly format a user entered URL correctly with http:// if it is not detected. This ensures consistency. <?php $formatted_url = htmlspecialchars(((!strpos($_POST['link'],"://") && $_POST['link'] != NULL) ? "http://".$_POST['link'] : $_POST['link'])) ?> ---- Server IP: 69.147.83.197 Probable Submitter: 83.67.97.73 ---- Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php Edit -- https://master.php.net/note/edit/97013 Del: integrated -- https://master.php.net/note/delete/97013/integrated Del: useless -- https://master.php.net/note/delete/97013/useless Del: bad code -- https://master.php.net/note/delete/97013/bad+code Del: spam -- https://master.php.net/note/delete/97013/spam Del: non-english -- https://master.php.net/note/delete/97013/non-english Del: in docs -- https://master.php.net/note/delete/97013/in+docs Del: other reasons-- https://master.php.net/note/delete/97013 Reject -- https://master.php.net/note/reject/97013 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167462) next »