Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial php代码为什么出错?

php代码为什么出错?

Jun 23, 2016 pm 02:17 PM

<html><head></head><body>kkk<?php   echo "html  php !";?></body></html>
Copy after login


Mozila Firefox 浏览器,只显示:kkk。
没有显示php代码部分,为什么?


回复讨论(解决方案)

php环境是否配置成功了?这段代码是放入html文件还是php文件?又是怎么访问的?
查看源码看php代码解析了没有。

php环境是否配置成功了?这段代码是放入html文件还是php文件?又是怎么访问的?
查看源码看php代码解析了没有。

文件名是:a.htm

应该是配置成功了,安装完Apache。输入网址:127.0.0.1,显示测试页面。

但是,为什么php代码显示不了?

把文件名改为:a.php   这样才能解析php代码

把文件名改为:a.php   这样才能解析php代码

1.上面源代码,混合了html语言,php语言。为什么文件名后缀一定是.php,才可以解析php代码?

2.如果,源代码有hmtl语言,php语言,javascript语言等多种语言混合在一起。那么,文件名后缀应该是什么?


把文件名改为:a.php   这样才能解析php代码

1.上面源代码,混合了html语言,php语言。为什么文件名后缀一定是.php,才可以解析php代码?

2.如果,源代码有hmtl语言,php语言,javascript语言等多种语言混合在一起。那么,文件名后缀应该是什么?

php结尾,有php代码就必须要php进行编译,编译后再给服务器,再发送给浏览器响应给用户,这个是流程

···文件名是htm 服务器怎么会去解析捏····改成php文件先

如果,多种语言混合,文件名后缀是什么?

如果,多种语言混合,文件名后缀是什么?
你用什么语言做编程就写什么后缀名,
php 语言用 .php  
.NET 语言用 .aspx  
等等

你现在用php编程,就要用.php后缀名。即使里面加有javascript(这个只是脚本语言)  html(简单点来讲就是模板) 后缀名也还是 .php

建议你多看看基础知识

你的代码本身并没有错!
你可以在浏览器中查看网页源代码时看到没有被执行的 php 代码

为什么没有执行,原因上面已经讲了

文件名必须是.php文件才能解析php代码

文件名必须是.php文件才能解析php代码

因为如果不用php后缀,那他怎么知道用什么解析?
其实也可以用html后缀,那就得改web服务器的设置了。
默认情况下是不会去解析html文件的。


文件名必须是.php文件才能解析php代码

因为如果不用php后缀,那他怎么知道用什么解析?
其实也可以用html后缀,那就得改web服务器的设置了。
默认情况下是不会去解析html文件的。

要使WEB服务器解析,源代码有php源码,扩展名是:html的网页。
WEB服务器怎样设置?

以 apache 为例 httpd.conf 里面有

AddType application/x-httpd-php .php4 .php3 .php  .htm .html .phtml .ph .inc

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Explain the concept of late static binding in PHP. Explain the concept of late static binding in PHP. Mar 21, 2025 pm 01:33 PM

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Customizing/Extending Frameworks: How to add custom functionality. Customizing/Extending Frameworks: How to add custom functionality. Mar 28, 2025 pm 05:12 PM

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

How to send a POST request containing JSON data using PHP's cURL library? How to send a POST request containing JSON data using PHP's cURL library? Apr 01, 2025 pm 03:12 PM

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

See all articles