Introduction: Busan Line, exposing human nature,
————————————————————————————————————————————————————————————————————————————
Today, one of the simplest examples is how to read a label from another HTML page in PHP and show what the user wants to output.
First create a page named: test.html as shown:
<!doctype html>{$content}</body>
Requirement: Read {$content} and output what the user wants to output.
Next create another page, the mytest.php code is as follows:
<?PHP//assigns a value to a $content, and is the form of a string$content= ' I've been reading Lio Yimei's "Clumsy Life like Me";//reads all the contents of the Test.html file and returns it as a string$fileContent=file_get_contents(' test.html ');//Replace {$content} with $content content from the $filecontent string and return the string$str=Str_replace(' {$content} ',$content,$fileContent);//Final output ContentEcho $str;?>
Finally, through the page access, you can access the content, the results are as follows:
Summary: This is actually just a basic example of PHP, but also a thought, mainly for the smarty to do bedding. If something is wrong, please correct me, thank you!!
In PHP, how to replace the label in a page with what the user wants to output