Php htmlspecialchars () function

Source: Internet
Author: User
Tags php script

Because Javascript (usually) client technology and PHP (usually) server technology are used, since HTTP is a "stateless" protocol, variables cannot be directly shared between the two languages.

However, people may use the relationship between variables. One way is to complete the creation of Javascript code using PHP, refresh the browser itself, and return the PHP script through specific variables. The following example exactly shows how to do this-it enables p hp code to capture the screen height and width, which is usually the only possible on the client. Htmlspecialchars () function

<? Php
Echo "<input type = 'ddn' 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 ();
}
?>

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.