Hi,
I want to be able to put the HTML of another page into a string. What is the best way to do this? I couldn't really thing of a better way to say this so if you don't understand just tell me and I'll try harder.
Thanks.
Only cavaet is to ensure that any single quotes " ' " are escaped (\'). Hence use normal quotes ' " ' for all strings where possible. Then you can printf$dat) or do whatever you want with it.
I've found using normal quotes in all instances where a variable name is not used is best practices for me. Then the above works with no sweat.
Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
(2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.
to you want to read or phrase the html? That will phrase it, this will read it in a n editalbe text box.
PHP Code:
<?php
if(empty($_GET['action'])){ //opens file to be edited
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=write" method="post">
<textarea name="contents" rows="10" cols="60">
<?php
//this part will open the html page into a text box
//if you mae changes to it you can click the submit buton to save changes
$fp=fopen("page_to_read.html", "r"); //this is the html pae you want to read. same as if you use the next section.
while (!feof($fp)){
$line=fgets($fp);
print stripslashes("$line");
}//end while
fclose($fp);
?> </textarea><br/><br />
<input type="submit" value="Submit" />
</form>
<?php
//if you are gong to save the chnages you need to modify the permissions of that page to chmod 777
}else{ //saves changes to the file selected if you make chages
$fp=fopen("page_to_read.html", "w"); //same file as above
fputs($fp, $_REQUEST['contents']);
if (fclose($fp)){
print "<h2>File successfully saved</h2>\n";
}else{
print "<h2><font style=\"color:red;\">There was a problem saving the file</font></h2>\n";
}
Hmmm... I get this error:
Warning: file_get_contents(http://www.yell.com/ucs/UcsSearchAct...&location=DE23 6HB&scrambleSeed=32581&searchType=classic&startOoaAt=10&ooascrambleSeed=32581&ooa=on): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/sftr/public_html/takeaway/index.php on line 7
And the ini function returns 1.
What's up with it?
Thanks.
Bookmarks