note 100995 added to function.strip-tags

From: Date: Fri, 19 Nov 2010 10:30:30 +0000
Subject: note 100995 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-174177@lists.php.net to get a copy of this message
Note that strip_tags may stumble when it encounters two consecutive quotes. Regardless of whether that's a bug or a feature (different PHP versions seem to behave differently) here's a workaround: <?php $wtf = ' <p>First line</p> <a href=\"foo">bar</a> <p>Second line</p> <a href=\"foo\"">bar</a> <p>Third line</p> '; echo 'Raw: ' . $wtf . "\n"; echo 'strip_tags(): ' . strip_tags ($wtf); echo 'Regexp: ' . preg_replace ('/<[^>]*>/', '', $wtf); ?> Raw output: <p>First line</p> <a href=\"foo">bar</a> <p>Second line</p> <a href=\"foo\"">bar</a> <p>Third line</p> strip_tags() output: First line bar Third line preg_replace() output: First line bar Second line bar Third line ---- Server IP: 69.147.83.197 Probable Submitter: 41.28.207.198 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/100995 Del: integrated -- https://master.php.net/note/delete/100995/integrated Del: useless -- https://master.php.net/note/delete/100995/useless Del: bad code -- https://master.php.net/note/delete/100995/bad+code Del: spam -- https://master.php.net/note/delete/100995/spam Del: non-english -- https://master.php.net/note/delete/100995/non-english Del: in docs -- https://master.php.net/note/delete/100995/in+docs Del: other reasons-- https://master.php.net/note/delete/100995 Reject -- https://master.php.net/note/reject/100995 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174177) next »