note 9160 deleted from function.str-replace by philip

From: Date: Mon, 04 Feb 2002 12:41:48 +0000
Subject: note 9160 deleted from function.str-replace by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-26208@lists.php.net to get a copy of this message
I used str_replace to make a php script that translates an HTML page into its PHP equivalent (the PHP code will so generate the original HTML page) : fputs($php_file,"<?");fputs($php_file,"\n"); while(!feof($html_file)) { $line = fgets($html_file,4096); $l = strlen($line); if(($line!="")&&($l>2)) {//removing chr(10) and chr(13) : $line = substr($line,0,strlen($line)-2); //Replacing the '"' of the HTML by '\"' in PHP code: $line2 = str_replace ("\"", "\\\"", "$line"); //Note : '\n' in JavaScript code should also be replaced // by '\\n' - to be done ... //Adding 'print("...");' : $newLine = "print(\""."$line2"."\\n\");"; fputs($php_file,$newLine); fputs($php_file,"\n"); } } fputs($php_file,"?>");fputs($php_file,"\n");

« previous php.notes (#26208) next »