note 123659 added to function.strpos

From: Date: Tue, 05 Mar 2019 17:50:13 +0000
Subject: note 123659 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-210325@lists.php.net to get a copy of this message
When a value can be of "unknow" type, I find this conversion trick usefull and more readable than a formal casting (for php7.3+): <?php $time = time(); $string = 'This is a test: ' . $time; echo (strpos($string, $time) !== false ? 'found' : 'not found'); echo (strpos($string, "$time") !== false ? 'found' : 'not found'); ?> ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.142 (proxied: 2a02:121f:31c6:0:c039:9428:769e:72ec) ---- Manual Page -- http://php.net/manual/en/function.strpos.php Edit -- https://master.php.net/note/edit/123659 Del: integrated -- https://master.php.net/note/delete/123659/integrated Del: useless -- https://master.php.net/note/delete/123659/useless Del: bad code -- https://master.php.net/note/delete/123659/bad+code Del: spam -- https://master.php.net/note/delete/123659/spam Del: non-english -- https://master.php.net/note/delete/123659/non-english Del: in docs -- https://master.php.net/note/delete/123659/in+docs Del: other reasons-- https://master.php.net/note/delete/123659 Reject -- https://master.php.net/note/reject/123659 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#210325) next »