Notes for PHPNEWBIE

Source: Internet
Author: User
Some notes for PHPNEWBIE: 1. variable transfer & nbsp; I am afraid this is the most common problem that everyone has seen. Some friends may ask: why did I install PHP, variables cannot be passed between pages? & Nbsp; after PHP4.2, change the setting of register_globals in PHP. INI to Off, which makes some precautions for PHP NEWBIE
Question 1: variable transfer

This is probably the most common problem. some people may ask: why cannot variables be transmitted between pages after I install PHP?

After PHP4.2, the setting of register_globals in PHP. INI is changed to Off, which makes some programs that can run earlier than 4.2 unexecutable.

This is because PHP itself has security risks when register_globals is set to On. When the program design is not strict, others can get the variables you pass between pages through some means (terrible problem ). There are two solutions: one is to reset register_globals in PHP. INI to On (don't you ?); The second is the global variable set prepared for us using PHP when passing variables between pages. As follows:

$ _ POST ['varname']; // A variable submitted in post mode. it is mostly used for form submission ( ).

$ _ GET ['varname']; // variable submitted in get mode, which can be used for from submission (), Can also be used to get the parameters of the page (http://test.php? A = OK ).

$ _ COOKIE ['varname'];

$ _ SESSION ['varname']; // Get the variables stored in the session and cookie.

In fact, the above variable names can all be written in another form: $ HTTP _ * _ VARS ['varname'], that is, $ HTTP_POST_VARS ['varname'], $ HTTP_GET_VARS ['varname'], $ HTTP_COOKIE_VARS ['varname'], $ HTTP_SESSION_VARS ['varname'], but it does not seem safe to write such a statement, therefore, we should adopt this easy-to-write and safe method.



Question 2: SESSION settings

Warning: open (tmp \ sess_a18eaa908774d31693cf91777599c90, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

When a SESSION is used in a program, some friends may ask the following question: why does the above warning appear on the SESSION page?

This will only happen in WINDOWS. This is because in PHP. in INI, the default SESSION storage path is session. save_path = '\ tmp', which is actually a * nix path, but this path does not exist in WINDOWS. So PHP cannot find the place where the SESSION is stored. of course, a warning should be issued. The solution is to replace '\ tmp' with the address of a directory in WINDOWS.

Another problem is that, when using the SESSION, to get the SESSION variable on the current page, you must add session_start () to the beginning of the program, and there cannot be any output before. In other words, it is best to write session_start () in the first line.



Question 3: maximum page execution time

When uploading a large file or reading a large amount of data from the database, the page may take a long time to execute. In PHP. INI, the maximum page execution time limit is max_execution_time = 30 by default. that is to say, when your program has been executed for 30 seconds, it will automatically stop responding. So when the program you want to execute takes a long time, you can modify max_execution_time = 300 or greater to ensure normal execution of the program. When uploading files, pay attention to the following settings:

Upload_max_filesize = 2 M // maximum file upload capacity

Post_max_size = 2 M // maximum file size submitted through the post method

Memory_limit = 8 M // maximum memory consumed during execution on each page





---------------------------

The general program setting max_execution_time = 30 should be enough.

Most of them are infinite loops.


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

What is MVP? Rare

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

Reference:

What is MVP? Rare
Introduction to Microsoft MVP (most valuable expert)
Microsoft's most valuable expert (MVP) is a professional who has one or more Microsoft technologies and actively participates in online or offline community activities. it often shares its knowledge and professional skills with other professionals, highly respected, trusted, and approachable expert.
In real life, people always trust experts' suggestions and feedback. Microsoft MVP is such a group of Microsoft technical experts with rich knowledge and practical experience. They are not Microsoft employees ......

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.