Php prompts Notice: Use of undefined constant error

Source: Internet
Author: User
Tags constant echo date php code php error

A large number of similar prompts will appear on the website, but they can be displayed and run normally.

A simple line of code like the following will produce the above error:

$ Str = coderbolg;

Although this can be run sometimes, problems may occur in some cases. When you see this error message, you can find the word in the quotation marks and find it to find the problem. This is usually because the quotation marks should be left blank where the string is used, or the $ symbol is missing when the variable should be used.

The default time zone of php is incorrect. Try to add

The code is as follows: Copy code


Date_default_timezone_set (PRC);/* Set the time to Beijing time, and php5 is the Greenwich Mean Time by default */

The system prompts Notice: Use of undefined constant PRC-assumed 'prc'. After PHP5.1.0, date_default_timezone_set is overwritten and PRC is invalid.

The code is as follows: Copy code

Date_default_timezone_set ("Asia/Shanghai ");

It is normal.

The code is as follows: Copy code

<? Php
Date_default_timezone_set ("Asia/Shanghai");/* Set the time to Shanghai time. php5 defaults to Greenwich Mean Time */
// Date_default_timezone_set ("Asia/Beijing"); // interestingly, Beijing time does not support
Echo date ('H: I: s ');
?>

These are PHP prompts rather than errors. PHP itself can be directly used without declaring variables in advance, but there will be prompts for UN-declared variables. Generally, when a website is a formal website, it will turn off the prompt and even the error message.

How to disable PHP prompts

Search for php. ini:

The code is as follows: Copy code

Error_reporting = E_ALL

Changed:

Error_reporting = E_ALL &~ E_NOTICE

There is another way to do this:

Add each file header

The code is as follows: Copy code
Error_reporting (0 );

Although it is difficult to solve the problem, it can solve the problem. If the php error is disabled, we will solve the problem if we can find the error, because I wrote a piece of php code before. If a lot of errors occur, we disable it, which will affect the program performance.

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.