How to output the answer and prompt an error? please refer to the code _ PHP Tutorial.

Source: Internet
Author: User
How can I output the answer and prompt an error? please refer to the code. How can I output the answer to the question and prompt an error? please refer to the code solution define (PI, 3.14); for ($ r1; $ r {$ areaPI * $ r; echor $ r, area $ area; echo ;}? Output error
How can I output the answer and prompt an error? please refer to the code.
Solution

Define (PI, 3.14 );

For ($ r = 1; $ r <= 8; $ r ++)
{
$ Area = PI * $ r;

Echo "r = $ r, area = $ area ";
Echo"
";
}

?>


The output error message is: Notice: Use of undefined constant PI-assumed 'pi 'in D: Program FilesApache GroupApache2htdocs123. php on line 3.


Reference answer
This is not an error. it's just "note". you can turn it off.
Add this at the top of the program
Error_reporting (E_ALL ^ E_NOTICE );
Reference answer
In define (), the second parameter must be enclosed in single quotation marks. Otherwise, the value assignment fails, causing the constant to be declared and errors will naturally occur during the call.
Reference answer
What should it pay attention? My code is correct!

In define, why should we put 3.14 in single quotes? isn't the PI value 3.14 clear?

I just learned PHP, but I really don't understand it ~~
Reference answer
Bool define (string $ name, mixed $ value [, bool $ case_insensitive])
No quotation marks are required. Otherwise, the string type is changed. you can check the gettype.
Reference answer
[Img] http://www.111cn.cn/bbs/images/smilies/default/sweat.gif#/img]
We recommend that you read the php syntax and then write the code, define (DZ, 'I'm not a big face modem '), the whole code means to set the value of the constant DZ to the character string 'I am not a big face modem' inside the single quotes '. what is obvious to you is not necessarily reasonable for the program.
Reference answer
Wrong. The first parameter should also be enclosed in single quotes. the fifth floor said that this is not so considerate for weak php languages, whether it is a string type depends on the operation you want to perform on it.
Reference answer
Define (DA, '123 ');

Define ('DB', '123 ');

Define ('DC', 123 );

Echo gettype (DZ), gettype (DB), gettype (DC );

The third is rigorous. Yes, it is because of the php language itself.



Reference answer
Develop good programming habits and be taught
Reference answer
Thank you!

Explain how to output the answer and prompt an error. please refer to the code solution define (PI, 3.14); for ($ r = 1; $ r {$ area = PI * $ r; echo "r = $ r, area = $ area"; echo "" ;}?> Output error...

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.