The example in this article describes the method of php outputting a string containing "#". Share it with everyone for your reference, the details are as follows:
Because # is a comment in php, it cannot be output normally and needs to be converted and processed.
Output page:
<? function zh($str) { for($i=0;$i<strlen($str);$i++) { if($str[$i]=="#") { $str[$i]="@"; } } return $str; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <a href="untitled.php?id=<?=zh('c#程序设计')?>">c#程序设计 </a> </body> </html>
Accepting and output page:
<? function zh_2($str) { for($i=0;$i<strlen($str);$i++) { if($str[$i]=="@") { $str[$i]="#"; } } return $str; } $id=$_GET["id"]; $a=zh_2($id); echo $a; ?>
I hope this article will be useful to everyone in PHP programming. helped.
For more articles related to methods of php outputting strings containing "#", please pay attention to the PHP Chinese website!