CentOS 下php的執(zhí)行,該如何解決
Jun 13, 2016 am 10:03 AM
CentOS 下php的執(zhí)行
我是剛學(xué)linux,php,安裝時(shí)選擇了centos系統(tǒng),安裝時(shí)選擇安裝了php apache,mysql,安裝后開啟了服務(wù)httpd,輸入http://127.0.0.1/后,能執(zhí)行html頁(yè),但php不能執(zhí)行,
在httpd.cong中加了LoadModule php5_module modules/libphp5.so
和AddType application/x-httpd-php .php,但運(yùn)行index.php是什么也沒有,也沒有報(bào)錯(cuò).請(qǐng)大家給指點(diǎn)一下,還有哪部沒有配好,才能執(zhí)行php,謝謝.
------解決方案--------------------
php解釋器沒有安裝吧,應(yīng)該是PHP沒有安裝好。。。
------解決方案--------------------
不知道你的LAMP環(huán)境是怎么安裝的!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

When writing PHP comments, you should clarify the purpose, logic and structure. 1. Each function and class uses DocBlock format to explain the role, parameters and return values; 2. Explain "why" in the key logic rather than just "what was done"; 3. Add a brief description at the top of the file, including functions, dependencies and usage scenarios; 4. Avoid nonsense comments, add only necessary instructions before complex logic, and do not record the modification history. This improves code readability and maintenance efficiency.

Comments are crucial in code because they improve the readability and maintenance of the code, especially in projects like PHP that are multi-collaborative and long-term maintenance. Reasons for writing comments include explaining “why do this” to save debugging time and be friendly to newbies and reduce communication costs. The representation of good comments includes explaining the role of functions or classes to explain complex logic intent marking to-dos or potential problems, and writing API interface documentation annotations. Typical manifestations of bad comments include repeated code content comments that are inconsistent with code and using comments to cover up bad code and retaining old information. Suggestions for writing comments include prioritizing comments "why" keeping comments synced with code Use a unified format to avoid emotional statements and consider optimizing code rather than relying on comments when the code is difficult to understand.

Defining constants in PHP, const is more suitable for constant definitions inside classes, and define() is more flexible and suitable for global or dynamic definitions. 1.const is a language structure, and must be a compile-time constant expression when defined, which is suitable for class or global namespaces; define() is a function, and the value can be the result of runtime calculation. 2.const is affected by the namespace, and the constants defined by define() are visible globally by default. 3. The const structure is clear and the IDE is good, which is suitable for object-oriented design; define() has high flexibility but may have higher maintenance costs. 4. define() supports runtime condition judgment and dynamic definition, but const does not support it. Therefore, class-related constants preferentially use co

PHP comparison operators need to pay attention to type conversion issues. 1. Use == to compare values only, and type conversion will be performed, such as 1=="1" is true; 2. Use === to require the same value as the type, such as 1==="1" is false; 3. Size comparison can be used on values and strings, such as "apple"

There are three common methods for PHP comment code: 1. Use // or # to block one line of code, and it is recommended to use //; 2. Use /.../ to wrap code blocks with multiple lines, which cannot be nested but can be crossed; 3. Combination skills comments such as using /if(){}/ to control logic blocks, or to improve efficiency with editor shortcut keys, you should pay attention to closing symbols and avoid nesting when using them.

When using if/else control structure for conditional judgment in PHP, the following points should be followed: 1. Use if/else when different code blocks need to be executed according to the conditions; 2. Execute if branches if the condition is true, enter else or elseif if they are false; 3. When multi-conditional judgment, elseif should be arranged in logical order, and the range should be placed in front of the front; 4. Avoid too deep nesting, it is recommended to consider switch or reconstruction above three layers; 5. Always use curly braces {} to improve readability; 6. Pay attention to Boolean conversion issues to prevent type misjudgment; 7. Use ternary operators to simplify the code in simple conditions; 8. Merge and repeat judgments to reduce redundancy; 9. Test boundary values to ensure the complete logic. Mastering these techniques can help improve code quality and stability.

PHP string processing requires mastering core functions and scenarios. 1. Use dot numbers or .= for splicing, and recommend arrays for splicing large amounts of splicing; 2. Use strpos() to search, replace str_replace(), pay attention to case sensitivity and regular usage conditions; 3. Use substr() to intercept, and use sprintf() to format; 4. Use htmlspecialchars() to output HTML, and use parameterized query to database operations. Familiar with these function behaviors can deal with most development scenarios.

The "undefinedindex" error appears because you try to access a key that does not exist in the array. To solve this problem, first, you need to confirm whether the array key exists. You can use isset() or array_key_exists() function to check; second, make sure the form data is submitted correctly, including verifying the existence of the request method and field; third, pay attention to the case sensitivity of the key names to avoid spelling errors; finally, when using hyperglobal arrays such as $_SESSION and $_COOKIE, you should also first check whether the key exists to avoid errors.
