日期:2014-05-16  浏览次数:20825 次

Windows 下整合 apache、php 和 mysql
01.安装 Apache HTTP Server

02.安装/解压 PHP

03.配置 Apache(httpd.conf)对 PHP 的支持

  # load the PHP module for Apache 2.x
  # Users of Apache 2.2 should note that the DLL file for Apache 2.2 is named php5apache2_2.dll rather than php5apache2.dll
  # and is available only for PHP 5.2.0 and later.
  LoadModule php5_module "c:/php5/php5apache2.dll"
 
  # enable PHP handling of any file that has a .php extension, even if there are other file extensions.(For example, example.php.txt)
  # To ensure that only files that end in .php are executed, use the following configuration instead:
  # <FilesMatch \.php$>
  #       SetHandler application/x-httpd-php
  # </FilesMatch>
  AddHandler application/x-httpd-php .php

  # configure the path to php.ini
  PHPIniDir "C:/php5"

04.显示错误信息
  error_reporting  =  ...
  display_errors = On

05.配置 PHP(php.ini) 以连接 MySql
  extension_dir = "c:/php5/ext"
  extension=php_mysql.dll
 
  httpd.exe 应用程序错误,该内存不能为 read 的解决方法:
  将C:\php5文件夹下的 libmysql.dll 和 php5ts.dll 拷到 C:\WINDOWS\system32 下



转:PHP Notice: undefined index 完美解决方法
原文链接:http://shuai.be/archives/php-undefined-index/

平时用$_GET[‘xx’] 取得参数值时,如果之前不加判断在未传进参数时会出现这样的警告:

    PHP Notice: undefined index xxx

虽然可以通过设置错误显示方式来隐藏这个提示,但是这样也有隐患,就是在服务器的日志中会记录这些提示,导致日志文件异常庞大!
下面是引用网上流行的解决方法:

    首先,这个不是错误,是warning。所以如果服务器不能改,每个变量使用前应当先定义。

    方法1:服务器配置修改
    修改php.ini配置文件,error_reporting = E_ALL & ~E_NOTICE

    方法2:对变量进行初始化,规范书写(比较烦琐,因为有大量的变量)。但还没有找到好定义方法,望大家指教

    方法3:每个文件头部加上:error_reporting(0); 如果不行,只有打开php.ini,找到display_errors,设置为display_errors = Off。以后任何错误都不会提示。
   
    方法4 :做判断:isset($_GET["page"]) if-else判断
    或者加上'@'表示这行如果有错误或是警告不要輸出
    如:@$page=$_GET["page"]

    方法5:file1.php文件把$xx变量付一个值,用post 传递给file2.php,
    如果file2.php没有$xx的定义,而直接使用$yy=$xx; 系统就会报错:"undifined variaable $xx", 如果file2.php的文件开始用$xx="";定义,那么file1.php的$xx值就传不过来了!
    file2.php里可以这样
    if(!isset($xx)) $xx="";

但Jones认为,这些方法都不太方便。你不妨这样解决:

    定义一个函数:

    function _get($str){
        $val = !empty($_GET[$str]) ? $_GET[$str] : null;
        return $val;
    }

    然后在用的时候,直接用 _get('str') 代替 $_GET['str'] 就行啦~

是不是很方便?