首页 > php函数 > php htmlspecialchars()函数

php htmlspecialchars()函数

由于使用Javascript (通常情况下)客户端的技术,和PHP (通常情况下)服务器端技术,自从HTTP是一种“无国籍”协议,两种语言不能直接共享变量。

然而,人们可能通过变量两者之间的关系。途径之一是完成这一创造Javascript代码用PHP ,并刷新浏览器本身,通过特定变量返回的PHP脚本。下面的例子恰恰说明如何做到这一点-它使P HP代码捕获屏幕的高度和宽度,这通常是唯一可能在客户端。htmlspecialchars()函数

<?php
    
echo "<input type='hidden' value='" htmlspecialchars($data) . "' />n"
;
?>

php url

<?php
    
echo "<a href='" htmlspecialchars("/nextpage.php?stage=23&data=" 
.
        
urlencode($data)) . "'>n"
;
?>

 <?php
if (isset($_GET['width']) AND isset($_GET['height'])) {
  // output the geometry variables
  echo "Screen width is: ". $_GET['width'] ."<br />n";
  echo "Screen height is: ". $_GET['height'] ."<br />n";
} else {
  // pass the geometry variables
  // (preserve the original query string
  //   -- post variables will need to handled differently)

  echo "<script language='javascript'>n";
  echo "  location.href="${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}"
            . "&width=" + screen.width + "&height=" + screen.height;n";
  echo "</script>n";
  exit();
}
?>

 

本文地址:http://www.phprm.com/function/3ee139e9fdf0725a3c21286541e411b5.html

转载随意,但请附上文章地址:-)

标签:none

发表留言