php htmlspecialchars()函數

來源:互聯網
上載者:User

由於使用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();
}
?>

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.