Hello, everyone. a new php beginner asked me a few questions.

Source: Internet
Author: User
Hello, I am a beginner in php. I have several questions: PHPcode1. $ a = 3; $ B = 2; echo (int) $ a/(int) $ B. why is the output 1.5? 2. Howcanyouhidethefactthatwebpagesarewrittenin Hello, new php beginners may ask a few questions
PHP code
  1. $ a = 3; $ B = 2; echo (int) $ a/(int) $ B why is the output 1.5? 2. How can you hide the fact that web pages are written in PHP? A. by using AddType application/X-httpd-php aspb. specify all file names without any dot and extensionc. by using. htaccess diretive in Apeched. all of the above3. explain Using Register Globals.




------ Solution --------------------
1. because 1)/is a division operator, not a division operator 2) (int) operator has a higher priority/
(Int) $ a/(int) $ B = 3/2 = 1.5

2. I select d

3. in the Using Register Globals scenario, the submitted variables can be directly used by the $ variable name.
However, security issues exist. we recommend that you do not use Register Globals.
------ Solution --------------------
(Int) acts on the variable, not the entire expression
(Int) ($ a/$ B); so the result is 1


2 In fact, these measures are not enough. it is best to re-compile apache, rewrite the web server output header, and hide the php information in the development language.

3 is a feature that is not recommended.
------ Solution --------------------
Upstairs two
In C, (int) a/(int) B is equal to 1.
This question comes from here.
The test site is the automatic transformation of the data type. why is the result of division between two integer types a floating point number?
------ Solution --------------------
Discussion
Upstairs two
In C, (int) a/(int) B is equal to 1.
This question comes from here.
The test site is the automatic transformation of the data type. why is the result of division between two integer types a floating point number?

------ Solution --------------------
Discussion

2 In fact, these measures are not enough. it is best to re-compile apache, rewrite the web server output header, and hide the php information in the development language.


------ Solution --------------------
It seems that something meaningless has gone. Or there is no need to do this.


Data type
The root cause is that php is too easy to convert data types, hoho

Strongly typed languages generally return results with higher precision among a and B.
Related Article

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.