note 92864 added to function.htmlspecialchars

From: Date: Wed, 12 Aug 2009 12:57:59 +0000
Subject: note 92864 added to function.htmlspecialchars
Groups: php.notes 
Request: Send a blank email to php-notes+get-159365@lists.php.net to get a copy of this message
Need to dump the source of page retrieved via <a href="http://us3.php.net/curl">CURL</a>? I found it's easily done with htmlspecialchars() eg; <?php function get_page($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_USERAGENT, 'some bot'); curl_setopt($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($curl, CURLOPT_REFERER, '-'); curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate'); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); ... curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_NOBODY, 0); curl_setopt($curl, CURLOPT_TIMEOUT, 10); $html = curl_exec($curl); curl_close($curl); return $html; } $text = disguise_curl($url); $new = htmlspecialchars($text, ENT_QUOTES); // here is the magic :) echo '<pre>' .$new. '</pre>'; ?> HTH ---- Server IP: 209.41.74.194 Probable Submitter: 64.81.172.194 ---- Manual Page -- http://www.php.net/manual/en/function.htmlspecialchars.php Edit -- https://master.php.net/note/edit/92864 Del: integrated -- https://master.php.net/note/delete/92864/integrated Del: useless -- https://master.php.net/note/delete/92864/useless Del: bad code -- https://master.php.net/note/delete/92864/bad+code Del: spam -- https://master.php.net/note/delete/92864/spam Del: non-english -- https://master.php.net/note/delete/92864/non-english Del: in docs -- https://master.php.net/note/delete/92864/in+docs Del: other reasons-- https://master.php.net/note/delete/92864 Reject -- https://master.php.net/note/reject/92864 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159365) next »