直接设置 .htaccess文件
之前用的是:
Options +ExecCGI
AddType application/x-httpd-php5-3 .htm .html .php
AddHandler x-httpd-php5-3 .htm .html .php
但是最近发现失效,改用下面方法:
<FilesMatch "\.html$">
SetHandler application/x-httpd-php
</FilesMatch>
现在可以直接在html文件中书写php代码了!
本文:PHP :html中直接运行php代码, Parsing .html as PHP in .htaccess for Apache 2.4

相关
Related Posts
-
PHP 比较两个文本文件差异 A diff implementation for PHP 实例DEMO:http://sources.ikeepstudying.com/diff/ Download Diff Download the file below and upload it to your web server. File Size Description class.Diff.php 11,230 bytes PHP class Comparing strings and files The compare function is used to compare two strings and determine the differences between them on a line-by-line basis. Setting the optional third parameter to true will change the comparison to be character-by-character. For example: // include the Diff class require_once './class.Diff.php'; // compare two strings line by line $diff = Diff::compare("line1\nline2", "lineA\nlineB"); // compare two strings character by character $diff = Diff::compare('abcmnz', 'amnxyz', true); The compareFiles function behaves identically, except that its first two parameters are paths to files: // include the Diff class require_once './class.Diff.php'; // compare two files line by…
PHP PDF 转 JPG 图片 Make PDF to JPEG Converter in PHPWe have published an article on How to Convert HTML to PDF in PHP with fpdf and received many emails to write something on conversion from PDF to JPEG so today I am going to show you how we can convert PDF to JPEG and its a 4 lines script and very easy and simple to understand. We use PHP imagick extension which is mostly built-in in PHP installation so no need to include any thing. <?php $imagick = new Imagick(); $imagick->readImage('mytest.pdf'); $imagick->writeImage('output.jpg'); ?> In this code we have to give a PDF file and in output it will produce JPEG files for each page of your given PDF file. If you want to convert first page of your PDF file only then define…
PHP 谷歌验证 google reCAPTCHA PHP client libraryProject page: http://www.google.com/recaptcha/ Repository: https://github.com/google/recaptcha Version: 1.1.1 License: BSD, see LICENSE Description reCAPTCHA is a free CAPTCHA service that protect websites from spam and abuse. This is Google authored code that provides plugins for third-party integration with reCAPTCHA. Manual installation If you wish to install the library manually (i.e. without Composer), an autoloader is provided assrc/autoload.php. You can require it in your script instead of the usual vendor/autoload.phpcreated by Composer. For example, require('/path/to/recaptcha/autoload.php'); $recaptcha = new ReCaptchaReCaptcha($secret); // etc. Usage First, register keys for your site at https://www.google.com/recaptcha/admin When your app receives a form submission containing the g-recaptcha-response field, you can verify it using: <?php $recaptcha = new ReCaptchaReCaptcha($secret); $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp); if ($resp->isSuccess()) { // verified! }…