PHP using JS pop-up error message garbled

Source: Internet
Author: User
Tags script tag
Problem Description: Submit data from the page to the background (non-AJAX submissions), when checking the legitimacy of the data, if there is an error, through the Echo out a section of JS code, error prompts. As follows

echo "";

The popup box will appear garbled.

Problem Analysis: If the browser is set to automatically detect the encoding, there will be no garbled, otherwise, garbled situation may occur. Because the script tag in the JS code is bare-Ben, no coding restrictions, so there will be garbled situation.

Problem solving: Wrap a layer of HTML code outside of the pop-up error message. As follows

$output =<<
 <>
  
 Eof;echo $output;
 

This way, when the error message pops up, there will be no more garbled cases.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The above is introduced in PHP using JS pop-up error message garbled, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.