在第一次学php时遇到的一个小白问题,请前辈们指导
以前一直用c,偶尔用c++、java,最近因为工作需要开始学php这种脚本语言,在ubuntu12.04上安装了php5、apache2、mysql。用《core php programming》这本书作为入门指导书,按书上的例子,写了下面这个示例脚本
保存为.html文件,然后用firefox打开,结果只显示html代码部分
去网上查了,网友说是因为html文件被交给浏览器直接解释,浏览器不识别php,按网友的的提示,在/etc/apache2/目录下找到httpd.conf文件,该文件是个空文件。我在里面添加了两行如下所示:
AddHandler php5-script .php .html
AddType text/html .php .html
重启后还是无法解释。然后我就想既然此路行不通,那就换个后缀试试,于是新建一个php文件,只写一行
firefox正常执行
但是,当我在这个.php文件里加入html代码时(后缀名还是.php)
firefox就又只显示html部分了
我的理解是按照后缀配置文件应该把.php交给php解释器来执行,即使只显示一部分,也应该是html部分被忽略,php部分被执行,为什么确实反过来的,理解不了,请前辈们指导一下,包括如何在静态html代码中嵌入php并且使其得到执行。
回复讨论(解决方案)
data turn to date
哈哈 data 写错了 date
好吧,,这个问题确实够小白的,感谢一楼二楼的朋友,分已经给你们了,因为一楼回答的早就给了他30分。

Hot AI Tools

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

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

Undress AI Tool
Undress images for free

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



Alipay PHP...

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,

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.

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

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

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