Frequently asked questions about PHP rookie

Source: Internet
Author: User
PHP Beginner FAQs

Top 14 Questions for beginners with a headache

Management reminder: This post is Haowubai perform a sticky action (2009-04-16) "1" Polygon cannot pass the variable get,post,session in the latest PHP version, the auto global variable is closed, so you have to get the argument from the previous side to use $_get[' Foo '],$_post[' foo '],$_session[' foo ' to get. Of course, you can also modify the automatic global variable to ON (php. ini to register_globals = on); Consider compatibility, or force yourself to be familiar with the new wording better.

"2" win under Apache using the Get method to pass Chinese parameters error:?

Test.php? a=, how are you, &b=?

Passing parameters will cause an internal error??
??
Workaround: "test.php a=". UrlEncode (Hello). " &b= ". UrlEncode (you're good too)?

"3" win under the session does not work properly?

PHP. ini default Session.save_path =/tmp?

This is obviously the configuration under Linux, win PHP cannot read and write the session file resulting in the session can not be used, change it to an absolute path, such as Session.save_path = C:windows emp?

"4" Display error message?

When php. ini display_errors = on and error_reporting = E_all, all errors and hints are displayed, preferably open for error correction when debugging, and if you use the previous PHP notation, most of the error messages are about undefined variables. Variables are called before they are assigned, and the solution is to detect or block.

For example, display $foo, can the IF (Isset ($foo)) echo $foo or echo @ $foo?

"5" Win under Mail () can't send e-mail?

SendMail configured under Linux can be sent, under win need to call the SMTP server to send e-mail, modify the php. ini = IP//IP is an SMTP server without authentication (hard to find online)?

PHP the best way to send mail is to send the socket directly to the other email server instead of forwarding the server.

"6" first installed MySQL if you do not have a password set, you should use the update mysql.user set password= "YourPassword" where user= "root" To change the password?

"7" header already sent?

This error usually occurs when you use the header, and he may be a couple of reasons: you pring or echo before you use the header. You have a blank line in front of your current file. You may include a file with a blank line or output at the end of the file.

"8" Changes after PHP. INI have not changed?

Restart the Web server, such as Iis,apache, and so on, before you apply the latest settings.

"9" PHP is installed on the 00 (ISAPI installation method request expert advice)?

PHP php Isapi.dll seems to conflict with 00, can only be installed in CGI mode?

Step one, first www.php. NET under a setup program, I am Loaded is: PHP-.. -installer.exe, you can also go to the latest version when installing PHP-.. -installer.exe before you make sure your IIS6.0 is up and able to access it. After installation,--> the application configuration in the default Web site.

Step Two: Click Web Service Extension--> to create a new Web service extension.

Step three: Extension-->php, then add?

Step four: Find the path to the PHP. exe to add it up.

Step five: OK, yes!??
??
Step six: Select PHP service Extensions, then click Allow.?

"10" Sometimes SQL statements do not work, the database operation failed, the simplest debugging method, echo that SQL, look at the value of the variable can get not.

What is the difference between "11" include and require?

There is not much difference, if the file to include does not exist, include prompt notice, and then continue to execute the following statement, require prompt fatal error and exit.

According to my test, the win platform they are first included after execution, so the included file is best not have include or require statements, which will cause the directory confusion. Perhaps *nux under different circumstances, not yet tested.?

If a file does not want to be included multiple times can be read by using include_once or require_once##, write the document data.?

function R ($file _name) {??
[Email protected] ($file _name, "R");??
[Email protected] ($filenum, lock_sh);??
[Email protected] ($filenum, FileSize ($file _name));??
[Email protected] ($filenum);??
return $file _data;??
}??
function W ($file _name, $data, $method = "W") {??
[Email protected] ($file _name, $method);??
Flock ($filenum, lock_ex);??
$file _data=fwrite ($filenum, $data);??
Fclose ($filenum);??
return $file _data;??
}??
What is the difference between "12" isset () and empty ()?

Both are test variables, but Isset () is the test variable is assigned, and empty () is the test of a variable that has been assigned is empty.

If a variable is not assigned to the reference in PHP is allowed, but there will be notice hint, if a variable is assigned a null value, $foo = "" or $foo=0 or $foo =false, then empty ($foo) return True, Isset ($foo) also return True, This means that the null value does not unregister a variable.
??
To unregister a variable, you can use Unset ($foo) or $foo=null?

"13" MySQL query statement contains keywords?

When PHP queries MySQL, sometimes MySQL table name or column name will have a keyword, this time the query will be error. For example, the table name is Order, the query will be error, the simple way is the SQL statement table name or column name plus ' [Tab key] to distinguish, such as SELECT * from ' order '?

"14" How to upload multiple files at once via HTTP protocol?

There are two ideas that are two implementations of the same method. Specific procedures also need to design themselves.

, set multiple file input boxes in the form, name their names with an array, as follows:?

??
??
??
??
??
In this way, the following tests are done on the server side:?

echo "

";??
Print_r ($_files);??
echo "
";??
, set multiple file input boxes in the form, but with different names, as follows:?

??
??
??
??
??
Do the same test on the server side:?

echo "

";??
Print_r ($_files);??
echo "
";?

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