6 common PHP error prompts and solutions, and php error prompts
In the php development process, I was confused about who to ask for help and thought I was not suitable for learning php. In fact, errors are common in everyone's learning process. Do not be arrogant. Many errors have already been told in the error code prompt. If you look at them carefully, you will not be able to use Baidu. Some common php errors are summarized to share with new php users.
Common Php errors
I. Fatal error: Call to undefined function ......
Function does not exist, possibleCause:
1. The system does not have this function and you have not defined it.
2. Someone will ask, I will not report an error on another machine. This is because the environment is different. This function is not enabled on the local machine. How can this function be enabled? You can find the dll of the function by using the Baidu function name and enable it in php. ini.
Example:Php fatal error: call to undefined function bcmul () Solution
When a server that handles network payment is migrated, it cannot be paid.
PHP environment:
PHP version 5.3.3
The system is Red Hat 4.1.2-54.
View the apache Error Log and find that an error is returned when the function bcmul () in the encrypted file:
Copy codeThe Code is as follows: PHP Fatal error: Call to undefined function bcmul () in/php_rsa.php on line xxx
Solution:
Run the following command:
Copy codeThe Code is as follows: yum install php-bcmath
The installation is complete.
If the following occurs:
Copy codeThe Code is as follows:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Base: mirrors.yun-idc.com
* Extras: mirrors.yun-idc.com
* Rpmforge: ftp.riken.jp
* Updates: mirrors.yun-idc.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-bcmath.x86_64. 1.6-40. el5_9 set to be updated
--> Processing Dependency: php-common = 5.1.6-40. el5_9 for package: php-bcmath
--> Running transaction check
---> Package php-common.x86_64. 1.6-40. el5_9 set to be updated
--> Processing Conflict: php53-common conflicts php-common
--> Finished Dependency Resolution
Php53-common-5.3.3-13.el5_9.1.x86_64 from installed has depsolving problems
--> Php53-common conflicts with php-common
Error: php53-common conflicts with php-common
You cocould try using -- skip-broken to work around the problem
You cocould try running: package-cleanup -- problems
Package-cleanup -- dupes
Rpm-Va -- nofiles -- nodigest
You just need to use yum update and then yum install php53-bcmath.
By the way, bcmath is an extension of PHP mathematics. You can use bcscale () to set the global default number of decimal places. The usage is as follows:
Copy codeThe Code is as follows: string bcmul (string $ left_operand, string $ right_operand [, int $ scale])
Example:
<?phpecho bcmul('1.34747474747', '35', 3); // 47.161echo bcmul('2', '4'); // 8?>
Options of this function in php. ini:
Copy codeThe Code is as follows:
[Bcmath]
; Number of decimal digits for all bcmath functions.
Http://www.php.net/manual/en/bc.configuration.php#ini.bcmath.scale
Bcmath. scale = 0
Ii. syntax error, unexpected T_STRING, expecting ......
Severe syntax errors, such as syntax error, unexpected T_STRING, expecting ',' or ';' in F: \ phpnow \ htdocs \ index. php on line 4
Mark the line number behind and check the punctuation of the line.
If the value is not added after echo 1 in the third line, an error is reported on line 4, on line 4, or the fourth line.
Example:
In fact, this is a very easy problem to solve. In my opinion, I have been familiar with it. I recently learned how to use JavaScript to declare variables using var.
In fact, you do not need to use var declaration in PHP, but when a variable is a member variable of a class, there is no problem in using var.
When var is used externally, the following error occurs: Parse error: syntax error, unexpected T_VAR in..., for example, my error message:
Parse error: syntax error, unexpected T_VAR in D: \ Apache2.2 \ htdocs \ shirdrn \ page \ p2 \ pageUtil. inc on line 34
I'm testing: An error occurred while using a class object defined by myself as a member of the class within a class.
Address. inc code corresponding to the address class:
<?phpclass Address {var $road;function Address(){}function setRoad($road){$this->road = $road;}}?>
The Person class and Its Test Code are as follows:
<?phprequire("address.inc");class Person {var $name;var $address;function Person(){}function display(){echo "Name : ".$this->name."<BR>";echo "Road : ".$this->address->road."<BR>";}}var $p = new Person();$p->address = new Address();$p->address->setRoad("Chagnchun Road");$p->name = "Shirdrn";$p->display();?>
The test output is abnormal:
Parse error: syntax error, unexpected T_VAR in D: \ Apache2.2 \ htdocs \ shirdrn \ page \ p2 \ pageUtil. inc on line 34
This is because var is used in the person. php code to declare variables. This is not the case in PHP. As long as the "$" symbol is used to start, it indicates that the character is followed by a PHP variable.
Haha :-)
Supplemented by other netizens:
Solution: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or, two days ago, we started our php journey and made a very common website. As a result, our php version is 5.0, the server version is 4.0. I was busy for a day yesterday. This morning, I found a solution in an article. Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}'. If "public" exists, remove "public. No error occurs. If "public" is the definition variable, change "public" to "var ".
Iii. Parse error: syntax error, unexpected T_VARIABLE in XXX. php on line XXX
This statement is a common PHP error. Generally, it is on the last line of line XXX or line XXX with a semicolon missing. Or use double quotation marks in double quotation marks without escaping.
Solution: Find the XXX line of XXX. php, find your own error according to the above analysis, and correct it.
Tip: as a programmer, you must be rigorous, clear-thinking, and careful. People are not sages, but try to avoid mistakes caused by carelessness so that they can become qualified programmers.
4. Parse error: syntax error, unexpected 'X' in XXX. php on line XXX
This statement is still a common PHP error. The error occurs in line XXX. php, which contains characters that cannot be recognized by PHP. It is often because functions, if, and other places that require '{', '}' are not closed, or a few characters are accidentally followed by ';' during programming.
Solution: Find the XXX line of XXX. php, delete the extra characters, and add the missing characters.
5. syntax error, unexpected $ end
When the logic forgets to close this error, there is a feature. He will prompt you to report an error in the last line of code. For example, if you have 30 rows in total, he will tell you on line 30. At this time, you should not check 30th rows, check 30 rows one by one to see which tag is not closed.
For a total of 3000 rows, he will tell you on line 3000. At this time, you should not check the 3000 rows. If your program layout is messy, it is very troublesome to find the brackets in the 3000 line ...... I will teach you a trick: ctrl + a ctrl + d alt + f4
Now you can rewrite it.
Another idea:
Parse error: syntax error, unexpected $ end in script. php on line xx
After debugging for a while, it is found that the line that produces the error is a line in the middle of the file.
// $ Str. = "?> \ N ";
Think of the line that the PHP interpreter allows to end with a single line comment, that is, // $ str. = "?> \ N "; is interpreted as a comment before the end mark. The comment content is // $ str. =", And?> \ N "; will be interpreted as HTML output for content outside the PHP block! The result is $ str. = "?> \ N "; after this line is added/annotated, there will be more?> The end mark of, resulting in the original real end mark as unexpected (unexpected.
The solution is to delete this line directly.
It is a good habit to write other things in the row where the PHP start and end tags are located.
6. Notice: Undefined varialbe :......
This is a common error. Solution: error_reporting: Adjust the error level,
The above are the six common PHP errors that we have shared with you. We have provided you with some general solutions and directions and hope they will help you in your learning.