PHP和MySQL的删除空白函数 (MySQL学习)
发布于 2008-08-05 10:41 阅读:24,940 评论:0 标签: MySQL PHP trim

    作为黄金搭档,PHP和MySQL都有自己的删除空白函数,而且函数名字也一样:trim(), ltrim(), rtrim()。当然,作为编程语言,PHP删除空白函数更为强大。

    对 ltrim()和rtrim(),从其英语解释来看:

以下是引用片段:
PHP为:Strip whitespace (or other characters)
MySQL为:space characters removed

    显然,PHP还可以有“other characters”,而且PHP的函数还可以用第二个参数自定义要删除的字符。

    对“other characters”,手册解释为:

以下是引用片段:
  • " " (ASCII 32 (0x20)), an ordinary space.
  • "\t" (ASCII 9 (0x09)), a tab.
  • "\n" (ASCII 10 (0x0A)), a new line (line feed).
  • "\r" (ASCII 13 (0x0D)), a carriage return.
  • "\0" (ASCII 0 (0x00)), the NUL-byte.
  • "\x0B" (ASCII 11 (0x0B)), a vertical tab.
  •     不过,MySQL的trim()函数也增加了对其他字符的删除。具体请见下面从手册上摘抄的解释。

    = = = = = = = = = = = = = 方便阅读的分隔线  = = = = = = = = = = = = = = = =

        以下为MySQL的函数解释

        LTRIM(str) 

        Returns the string str with leading space characters removed.

    以下是代码片段:
    mysql> SELECT LTRIM('  barbar');
            -> 'barbar'


        This function is multi-byte safe.

        RTRIM(str)

        Returns the string str with trailing space characters removed.

    以下是代码片段:
    mysql> SELECT RTRIM('barbar   ');
            -> 'barbar'

        This function is multi-byte safe.

        TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str), TRIM([remstr FROM] str)

        Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING, or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.

    以下是代码片段:
    mysql> SELECT TRIM('  bar   ');
            -> 'bar'
    mysql> SELECT TRIM(LEADING 'x' FROM 'xxxbarxxx');
            -> 'barxxx'
    mysql> SELECT TRIM(BOTH 'x' FROM 'xxxbarxxx');
            -> 'bar'
    mysql> SELECT TRIM(TRAILING 'xyz' FROM 'barxxyz');
            -> 'barx'

        This function is multi-byte safe.

        参考:
        php手册
        mysql中英文手册:
        http://dev.mysql.com/doc/refman/5.1/zh/functions.html
        http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_trim

    展开全文  
    收起全文  
    PHP显示出错提示的三种方法 (PHP心得)
    发布于 2008-05-16 20:04 1 阅读:25,521 评论:1 标签: php 出错提示 方法

      PHP在页面上显示出错消息并让用户看见是开发人员怎么样也不愿意面对的,但是谁都不想在一台没有配置成显示出错消息的服务器上用PHP开发代码。开发时显示PHP的错误消息对开发人员来说是个明智的选择,所谓工具是使人方便的,就是如此。

      下面来说说显示PHP错误提示消息的三个方法。

      一:php.ini配置

      php.ini配置中与此相关的有两个配置变量。下面是这两个变量及其默认值:

    以下是引用片段:
    display_errors = Off
    error_reporting = E_ALL & ~E_NOTICE

      display_errors 变量的目的很明显 ―― 它告诉PHP是否显示错误。默认值是 Off。现在我们的目的是显示错误提示,那么:

    以下是引用片段:
    display_errors = On

      E_ALL,这个设置会显示从不良编码实践到无害提示到出错的所有信息。E_ALL 对于开发过程来说有点太细,因为它连变量未初始化也显示提示,而这一点正是PHP“高级”的一个特征。幸好,error_reporting的默认值是“E_ALL & ~E_NOTICE”,这样就只看到错误和不良编码了,对程序无不利的提示则不会显示。

      修改php.ini后需要重新启动Apache,这样才可以在apache中生效,当然你如果只在命令行下测试程序,是不需要这一步的。

      二:Apache的httpd.conf和.htaccess配置

      如果要在.htaccess 文件中的指令来修改 PHP 的配置设定。需要有“AllowOverride Options”或“AllowOverride All”权限才可以。 请参见:AllowOverride 指令http://lamp.linux.gov.cn/Apache/ApacheMenu/mod/core.html#allowoverride

      AllowOverride指令确定允许存在于.htaccess文件中的指令类型,它仅在不包含正则表达式的配置段中才是有效的。

      如果此指令被设置为None ,那么.htaccess文件将被完全忽略。事实上,服务器根本不会读取.htaccess文件。

      当此指令设置为 All时,所有具有".htaccess"作用域的指令都允许出现在.htaccess文件中。

      例如以下指令只允许在.htaccess中使用AuthConfig和Indexes组的指令:

    以下是引用片段:
    AllowOverride AuthConfig Indexes

      .htaccess里的设置和httpd.conf是一样的。

      要在做在httpd.conf实现这一功能,需要把下列各行添加到 httpd.conf,以覆盖php.ini文件做出的配置:

    以下是引用片段:
    php_flag  display_errors        on
    php_value error_reporting       2039

      这会覆盖在 php.ini 文件中为 display_errors 已经设置的标志,以及 error_reporting 的值。值 2039 代表 E_ALL & ~E_NOTICE。如果愿意采用 E_ALL,请把值设为 2047。同样,还是要重启 Apache。

      httpd.conf对php宏定义设置的具体用法可以参见:http://www.php.net/manual/zh/configuration.changes.php

      你可以注意到,上面我们没有使用“E_ALL & ~E_NOTICE”这样的宏定义。这是因为这些宏定义都是php的变量,apache是不认识的,所以我们使用与其等同的值来设置。相关的信息和说明请见:http://www.php.net/manual/zh/ref.errorfunc.php#errorfunc.constants

      下面给出一个简单的对应值:

    以下是引用片段:
    值 宏定义
    1 E_ERROR 
    2 E_WARNING 
    4 E_PARSE 
    8 E_NOTICE 
    16 E_CORE_ERROR 
    32 E_CORE_WARNING 
    64 E_COMPILE_ERROR 
    128 E_COMPILE_WARNING 
    256 E_USER_ERROR 
    512 E_USER_WARNING 
    1024 E_USER_NOTICE 
    6143 E_ALL 
    2048 E_STRICT 
    4096 E_RECOVERABLE_ERROR

      三:程序中改变

      以上所介绍的都是配置文件里面做设置,如果你没有这个权限,或者只想测试一个程序,那么你可以使用两个函数来做到这一点。

      它们分别是:

    以下是引用片段:
    string ini_set ( string $varname , string $newvalue )

    int error_reporting ([ int $level ] )

      两个函数大同小异,error_reporting()看上去是ini_set()的error_reporting功能版。事实上我认为也的确如此。

      在ini_set()中你可以设置display_errors和error_reporting的值,而在error_reporting()中你只能设置error_reporting的值,也就是说,如果服务器默认不显示错误提示,你在error_reporting()中怎么变换都是不管用的。两个函数的参数都可以参见上面提到的数字--宏定义对应值。

      需要注意,以上两个函数的适用用时间为该函数起,一直到程序结束。它们不会影响到其他的程序。

      最后:关于PHP的宏定义

      最后,仍需要说明一点:无论httpd.conf还是ini_set()所设置的宏定义并不是无限的,更多的宏定义值请参看手册中的“php.ini 配置选项列表”:http://www.php.net/manual/zh/ini.php

      在里面列表中有一列为“可修改范围”,里面的值为PHP_INI_* ,所以在使用时需要看清宏定义的可修改范围。在列表的末尾,手册中有提示:

    以下是引用片段:
    PHP_INI_* 常量的定义
    常量 值 含义
    PHP_INI_USER 1 配置选项可在用户的 PHP 脚本或 Windows 注册表中设置
    PHP_INI_PERDIR 2 配置选项可在 php.ini, .htaccess 或 httpd.conf 中设置
    PHP_INI_SYSTEM 4 配置选项可在 php.ini or httpd.conf 中设置
    PHP_INI_ALL 7 配置选项可在各处设置

      本文参考资料:

    以下是引用片段:

    PHP 程序员的调试技术
    http://www.ibm.com/developerworks/cn/opensource/os-debug/

    AllowOverride 指令
    http://lamp.linux.gov.cn/Apache/ApacheMenu/mod/core.html#allowoverride

    怎样修改配置设定
    http://www.php.net/manual/zh/configuration.changes.php

    php.ini 配置选项
    http://www.php.net/manual/zh/ini.php

    运行时配置
    http://www.php.net/manual/zh/ref.errorfunc.php#ini.error-reporting

    ini_set()
    http://www.php.net/manual/zh/function.ini-set.php

    error_reporting()
    http://www.php.net/manual/zh/function.error-reporting.php

    display_errors
    http://www.php.net/manual/zh/ref.errorfunc.php#ini.display-errors

    预定义常量
    http://www.php.net/manual/zh/ref.errorfunc.php#errorfunc.constants

    展开全文  
    收起全文  
    PHP字符串类型转化的例子 (PHP心得)
    发布于 2008-03-28 13:01 1 阅读:12,129 评论:1 标签: PHP 类型

    以下是代码片段:
    if('dgfdg' == 0)
       echo 'Yes';
    else
       echo 'No';
    ?>

      上面的程序会输出什么?这个例子是从其他blog上看见的,时间长了记不清是那个blog了。这个blog上说,如果答不出来说明基础知识还不够。偶很惭愧,觉得自己的回答没有底气。于是实践了一下。

      发现这是个PHP类型转换的例子,字符串与数字同时操作的时候,字符串会转化为整型,看下面的例子

    以下是引用片段:
    [root@login yayu]# php -r "if('gfd' == 0) echo 'Yes'; else echo 'No'; echo \"\n\";"
    Yes
    [root@login yayu]# php -r "if('gfd544' == 0) echo 'Yes'; else echo 'No'; echo \"\n\";"
    Yes
    [root@login yayu]# php -r "if('56gfd544' == 0) echo 'Yes'; else echo 'No'; echo \"\n\";"
    No
    [root@login yayu]# php -r "if('5gfd544' == 5) echo 'Yes'; else echo 'No'; echo \"\n\";"
    Yes

      再看一下,字符串是如何转化为整型的:

    以下是引用片段:
    [root@login shengting]# php -r "echo (int) 10; echo \"\n\";"
    10
    [root@login shengting]# php -r "echo (int) '10gdfgfd'; echo \"\n\";"
    10
    [root@login shengting]# php -r "echo (int) 'gdfgfd'; echo \"\n\";"
    0
    [root@login shengting]# php -r "echo (int) 'gdfgfd10'; echo \"\n\";"
    0

      从上面可以看出,转换的时候和第一个字符有很大关系。纯字母会直接转换为0,字母开头的字符串也会转换为0,只有以数字开头才会转换为该字符串前几个数字,此时有字母在后则完全截断了。

      下面是手册上的例子:

    以下是代码片段:
    $foo "10.5";                // $foo is float (11.5)
    $foo "-1.3e3";              
    // $foo is float (-1299)
    $foo "bob-1.3e3";           
    // $foo is integer (1)
    $foo "bob3";                
    // $foo is integer (1)
    $foo "10 Small Pigs";       
    // $foo is integer (11)
    $foo "10.2 Little Piggies"
    // $foo is float (14.2)
    $foo "10.0 pigs " 1;          
    // $foo is float (11)
    $foo "10.0 pigs " 1.0;        
    // $foo is float (11)
    ?>

    展开全文  
    收起全文  
    PHP加速器eAccelerator文档翻译 (PHP心得)
    发布于 2007-11-06 11:02 1 阅读:62,081 评论:1 标签: eAccelerator Linux PHP 翻译 文档

      前端时间用到这个,看了一下英文文档觉得还是看最原始的资料看到的东西最全。比如说eAccelerator自带了共享内存管理的程序,这个在我找到的中文资料里面就没有看到过。

      本文翻译的是:Release-0.9.5.2 ,官网是:http://www.eaccelerator.net/。原文附后,英文水平不高,如果您发现有不对的地方,还请告诉我!

    --------------------------

    PHP的eAccelerator
    =====================

    什么是eAccelerator?
    ----------------------
    eAccelerator是一个的免费、开源的PHP模块,它能够为提供PHP加速、优化、加码、和动态内容缓存功能。它通过存储PH脚本编译后的状态而加快执行PHP脚本的速度,而不需要频繁的编译这个PHP脚本。而且它能优化PHP脚本,以提高执行PHP的速度。eAccelerator特色是减少了服务器负载、使PHP脚本加速1-10倍。

    eAccelerator是TurckMMCache的一个分支
    (请详见Dmitry Stogov维护的:http://sourceforge.net/project/turckmm-cache/

    eAccelerator把编译好的PHP程序存储在共享内存里面,并直接在这里面执行程序。但在共享内存里面寻找编译好的PHP程序时,会在很短的时间内产生一些锁定,所以一个程序可以被多个进程同时执行。不适合放入共享内存的文件将被缓存到硬盘上。

    eAccelerator包含了一个PHP加码器和解释器(loader????)。你可以使用encoder.php对你的程序加码,这样在分发程序的时候就可以不给出源码了。加码后的文件可以在任何机子上运行,只要它装有eAccelerator的PHP。加码后的代码不能被恢复,因为它是以编译完了的形式而存储的,而且存储时不包含源码。当然,程序中一些内部的东西可以使用反编译工具(different  reverse  engineering  tools)还原(例如:disassemblers, debuggers等等),但这并不是重要的。

    eAccelerator可以和Zend Optimizer的加码器共存。但是在php.ini中Zend Optimizer必须在eAccelerator配置参数的后面。如果你不使用Zend Optimizer的加码器,我们不推荐同时安装Zend Optimizer

    eAccelerator不能在CGI模式下运行,但是它能在一些web服务器下的Fast-CGI模式运行,比如:lighttpd。

    下面是一些能提供相同作用的产品:
     - Zend Performance Suite (http://www.zend.com/)
     - Alternative PHP Cache (http://pecl.php.net/package/APC)

    下载
    --------
    最新的eAccelerator版本能在下面的页面下载:
    http://sourceforge.net/projects/eaccelerator/
    版本控制的快照在:
    http://snapshots.eaccelerator.net

    要求:
    --------
    apache >= 1.3, mod_php >= 4.1, linux下工具:autoconf, automake, libtool, m4

    兼容性:
    --------
    eAccelerator能与PHP4、PHP5很好的工作,对PHP5.1版本还没很好的兼容。它能使用在Linux, FreeBSD, MacOS X,
    Solaris 和 Windows 下的 apache 1.3 and 2, lighttpd 和 IIS.

    快速安装:
    -------------

    你可以在下面的网站上找到更多的安装信息:
    http://eaccelerator.sourceforge.net/

    注意:在Microsoft Windows下安装,请参考README.win32文件

    第一步:编译eaccelerator

      export PHP_PREFIX="/usr"
     
      $PHP_PREFIX/bin/phpize
     
      ./configure \
      --enable-eaccelerator=shared \
      --with-php-config=$PHP_PREFIX/bin/php-config
     
      make

      你必须使用“export”命令指明PHP的安装路径的前缀,它可能是"/usr" "/usr/local",或其它

    第二布:安装 eAccelerator

      make install

    第三步:配置 eAccelerator

      eAccelerator能做为Zend或PHP的扩展。

    对于大于0.9.1版本的eaccelerator,如果你有/etc/php.d目录,你应该复制eaccelerator.ini到里面去,当然你可以根据你的需要修改它。

    如果没有,你需要修改你的php.ini文件(通常是/etc/php.ini)

    作为Zend的扩展:

      zend_extension="/usr/lib/php4/eaccelerator.so"
      eaccelerator.shm_size="16"
      eaccelerator.cache_dir="/tmp/eaccelerator"
      eaccelerator.enable="1"
      eaccelerator.optimizer="1"
      eaccelerator.check_mtime="1"
      eaccelerator.debug="0"
      eaccelerator.filter=""
      eaccelerator.shm_max="0"
      eaccelerator.shm_ttl="0"
      eaccelerator.shm_prune_period="0"
      eaccelerator.shm_only="0"
      eaccelerator.compress="1"
      eaccelerator.compress_level="9"

      如果你使用thread safe模式安装的PHP,你应该使用“zend_extension_ts”代替“zend_extension”

    作为PHP的扩展:

      extension="eaccelerator.so"
      eaccelerator.shm_size="16"
      eaccelerator.cache_dir="/tmp/eaccelerator"
      eaccelerator.enable="1"
      eaccelerator.optimizer="1"
      eaccelerator.check_mtime="1"
      eaccelerator.debug="0"
      eaccelerator.filter=""
      eaccelerator.shm_max="0"
      eaccelerator.shm_ttl="0"
      eaccelerator.shm_prune_period="0"
      eaccelerator.shm_only="0"
      eaccelerator.compress="1"
      eaccelerator.compress_level="9"
     
    第四步:建立缓存目录

      mkdir /tmp/eaccelerator
      chmod 0777 /tmp/eaccelerator

     

    配置选项
    --------

    eaccelerator.shm_size
     eAccelerator使用共享内存的总数。单位是MB.
     设置为“0”,则为操作系统默认值。默认为“0”

    eaccelerator.cache_dir
     硬盘缓存的目录。eAccelerator存储预编译代码,session数据,内容数据(content)和使用的入口(entres??)。这些数据也能够存储在共享内存里(为了得到更快的通道)。默认为“/tmp/eaccelerator”。

     yayu:建立这个空目录后,在有人访问php页面后会自动建立二级二维目录(0,1.....e,f)(16进制,晕)

    eaccelerator.enable
     决定eAccelerator是否有效。“1”为有效,“0”为无效。默认为“1”

    eaccelerator.optimizer
     是否使用内置的优化工具加速代码的执行。“1”为是,“0”为否。默认为“1”

    eaccelerator.debug
     是否记录eAccelerator debug log。“1”为是,“0”为否。默认为“0”

    eaccelerator.check_mtime
     是否检查php程序更新时间。“1”为是,“0”为否。如果你想改变php程序后重编译程序到共享内存,那就应该设置为“1”。默认为“1”

    eaccelerator.filter
     决定哪些php文件被缓存。你可能需要指定哪些文件(如:"*.php *.phtml")需要被缓存。如果在文件前加上“!”,那么符合条件的文件将被忽略。默认为"",这以为着所有php文件都会被缓存。

    eaccelerator.shm_max
     设置诸如“eaccelerator_put()”之类的函数能往共享内存里面加载数据的大小。单位为MB。“0”为不限制,默认为“0”。

    eaccelerator.shm_ttl
     当共享内存空间已满,将删除在“shm_ttl”秒前没有使用的程序。默认为0,为不删除任何文件。

    eaccelerator.shm_prune_period
     共享内存已满。前一次操作是在shm_prune_period秒之前,那么这一次将删除所有的旧程序。默认为“0”,意为不删除任何程序。

    eaccelerator.shm_only
     是否把编译后程序缓存到硬盘上。这个选项对session数据和内容(content)缓存无效。默认为“0”,意为同时使用共享内存和硬盘做缓存。

    eaccelerator.compress
     是否对缓存内容做压缩。默认为“1”,为不压缩。

    eaccelerator.compress_level
     压缩的级别,默认和最高都为“9”。

    eaccelerator.name_space
     一个对所有键值假拟的字符串。通过在.htaccess文件中设置的这个值,允许两个应用使用相同的键值运行在同一个主机上。

     yayu:命名空间?

    eaccelerator.keys
    eaccelerator.sessions
    eaccelerator.content
     决定那些键,session数据和内容将被缓存,这些可能的值是:

     "shm_and_disk" - 缓存数据在共享内存和硬盘上(默认值)
     "shm"          - 缓存数据在共享内存,如果共享内存已满或者提交的数据大小超过eaccelerator.shm_max,则存储在硬盘上。
     "shm_only"     - 只缓存数据在共享内存
     "disk_only"    - 只缓存数据在硬盘
     "none"         - 不缓存数据

    eaccelerator.allowed_admin_path
     允许得到管理信息和管理操作的脚本路径。


    控制面板及反汇编
    ---------------

    如果你要使用控制面板,你需要在编译eAccelerator时加上 --with-eaccelerator-info选项,这个是默认值。

    复制control.php文件到你的跟目录下,并且设置这个路径到php.ini 或者 eaccelerator.ini的eaccelerator.allowed_admin_path选项。如果你不这样做,你将看不到更多的相关信息,也不能控制eAccelerator。

    你可以在control.php文件中设置用户名和密码以进入控制面板

    当你使用--with-eaccelerator-disassembler编译时,你需要把dasm.php和PHP_Highlight.php也放到control.php目录里面。反汇编需要在编译PHP时加上对tokenizer的支持(--enable-tokenizer)
    你可以在dasm.php文件的上面得到执行反汇编时的用户名和密码


    eAccelerator 函数
    -----------------

    函数文档请看: http://bart.eaccelerator.net/doc/phpdoc/

    联系我们
    --------
    当你有疑问、需要补丁,提交bug,请发email给 Bart Vanbrabant

    --------------------------

    以下是英文全文:

    eAccelerator for PHP
    =====================

    What is eAccelerator?
    ----------------------
    eAccelerator is a free open source PHP  accelerator,  optimizer,  encoder  and
    dynamic content cache for PHP. It increases  performance  of  PHP  scripts  by
    caching them in compiled state, so that the overhead of  compiling  is  almost
    completely eliminated. It also optimises  the  script  to speed  up  execution
    of PHP scripts. eAccelerator typically reduces server load and  increases  the
    speed of your PHP code by 1-10 times.

    eAccelerator is a fork of TurckMMCache
    ( http://sourceforge.net/project/turckmm-cache/  by Dmitry Stogov )

    eAccelerator stores compiled PHP scripts in shared memory  and  executes  code
    directly from it. It creates  locks  only  for  short  time,  while  searching
    compiled PHP script in the cache, so one script can be executed simultaneously
    by several engines. Files that can't fit in shared memory are cached  on  disk
    only.

    eAccelerator contains a PHP encoder and loader. You  can  encode  PHP  scripts
    using encoder.php in order to distribute them without sources.  Encoded  files
    can be run on any site which  runs  PHP  with  eAccelerator.  The  sources  of
    encoded scripts can't be restored because they are stored in a  compiled  form
    and the encoded version doesn't contain the source. Of course, some  internals
    of the scripts can  be  restored  with  different  reverse  engineering  tools
    (disassemblers, debuggers, etc), but it is not trivial.

    eAccelerator is compatible with Zend Optimizer's loader. Zend  Optimizer  must
    be installed after eAccelerator in php.ini. If you don't use  scripts  encoded
    with  Zend  Encoder  we  do  not  recommend  to  install  Zend  Optimizer with
    eAccelerator.

    eAccelerator does not work in CGI mode but it does work in Fast-CGI mode with
    webservers like lighttpd.


    Here are some other products that provide the same functionality:

     - Zend Performance Suite (http://www.zend.com/)
     - Alternative PHP Cache (http://pecl.php.net/package/APC)

    Download
    --------
    Latest eAccelerator versions can be downloaded at the sourceforge page:
    http://sourceforge.net/projects/eaccelerator/
    Development snapshots from cvs can be downloaded at
    http://snapshots.eaccelerator.net


    Requirements
    ------------
    apache >= 1.3, mod_php >= 4.1, autoconf, automake, libtool, m4


    Compatibility
    -------------
    eAccelerator has been reported working with php4 and php5, php 5.1 support
    hasn't been integrated yet. It is being used on Linux, FreeBSD, MacOS X,
    Solaris and Windows with apache 1.3 and 2, lighttpd and IIS.


    Quick install
    -------------

    You can find more information about installation on eAccelerator website.
    http://eaccelerator.sourceforge.net/

    Note(1): for Microsoft Windows installation, please refer to README.win32 file.

    Step 1. Compiling eAccelerator

      export PHP_PREFIX="/usr"
     
      $PHP_PREFIX/bin/phpize
     
      ./configure \
      --enable-eaccelerator=shared \
      --with-php-config=$PHP_PREFIX/bin/php-config
     
      make

      You must specify the real prefix where PHP is installed in the "export"
      command. It may be "/usr" "/usr/local", or something else.

    Step 2. Installing eAccelerator

      make install

    Step 3. Configuring eAccelerator

    eAccelerator can be installed both as Zend or PHP extension.

    For eaccelerator > 0.9.1, if you have /etc/php.d directory, you should copy eaccelerator.ini inside and modify default value if you need.

    If not, you need to edit your php.ini file (usually /etc/php.ini).

    To install as Zend extension:

      zend_extension="/usr/lib/php4/eaccelerator.so"
      eaccelerator.shm_size="16"
      eaccelerator.cache_dir="/tmp/eaccelerator"
      eaccelerator.enable="1"
      eaccelerator.optimizer="1"
      eaccelerator.check_mtime="1"
      eaccelerator.debug="0"
      eaccelerator.filter=""
      eaccelerator.shm_max="0"
      eaccelerator.shm_ttl="0"
      eaccelerator.shm_prune_period="0"
      eaccelerator.shm_only="0"
      eaccelerator.compress="1"
      eaccelerator.compress_level="9"

      If you use thread safe build of PHP you must use "zend_extension_ts" instead
      of "zend_extension".

    To install as PHP extension:

      extension="eaccelerator.so"
      eaccelerator.shm_size="16"
      eaccelerator.cache_dir="/tmp/eaccelerator"
      eaccelerator.enable="1"
      eaccelerator.optimizer="1"
      eaccelerator.check_mtime="1"
      eaccelerator.debug="0"
      eaccelerator.filter=""
      eaccelerator.shm_max="0"
      eaccelerator.shm_ttl="0"
      eaccelerator.shm_prune_period="0"
      eaccelerator.shm_only="0"
      eaccelerator.compress="1"
      eaccelerator.compress_level="9" 

    Step 4. Creating cache directory

      mkdir /tmp/eaccelerator
      chmod 0777 /tmp/eaccelerator


    Configuration Options
    ---------------------

    eaccelerator.shm_size
        The amount of shared memory (in megabytes) that eAccelerator will use.
        "0" means OS default. Default value is "0".

    eaccelerator.cache_dir
        The directory that is used for disk cache. eAccelerator stores precompiled
        code, session data, content and user entries  here. The same data  can  be
        stored in shared memory also (for more quick access). Default value is
        "/tmp/eaccelerator".

    eaccelerator.enable
        Enables or disables eAccelerator. Should be "1" for enabling  or  "0"  for
        disabling. Default value is "1".

    eaccelerator.optimizer
        Enables or disables internal peephole optimizer which may  speed  up  code
        execution. Should be "1" for enabling or "0" for disabling. Default  value
        is "1".

    eaccelerator.debug
        Enables or disables debug logging. Should be "1" for enabling or  "0"  for
        disabling. Default value is "0".

    eaccelerator.check_mtime
        Enables or disables PHP file modification checking .  Should  be  "1"  for
        enabling or "0" for disabling. You should set it to "1"  if  you  want  to
        recompile PHP files after modification. Default value is "1".

    eaccelerator.filter
        Determine which PHP files must be cached. You may specify  the  number  of
        patterns (for example "*.php *.phtml") which specifies to cache or not  to
        cache. If pattern starts with the character "!", it means to ignore  files
        which are matched by the following pattern. Default value is "" that means
        all PHP scripts will be cached.

    eaccelerator.shm_max
        Disables putting large values into shared memory by " eaccelerator_put() "
        function. It indicates the largest allowed size in bytes (10240, 10K, 1M).
        The "0" disables the limit. Default value is "0".

    eaccelerator.shm_ttl
        When eaccelerator fails to get shared memory for new script it removes all
        scripts which were not accessed  at  last "shm_ttl"  seconds  from  shared
        memory. Default value is "0" that means -  don't  remove  any  files  from
        shared memory.

    eaccelerator.shm_prune_period
        When eaccelerator fails to get shared memory for new script  it  tryes  to
        remove  old  script   if   the   previous   try   was   made   more   then
        "shm_prune_period" seconds ago. Default value is "0" that  means  -  don't
        try to remove any files from shared memory.

    eaccelerator.shm_only
        Enables or disables caching of compiled scripts on disk. It has  no  effect
        on session data and content caching. Default value is "0" that means -  use
        disk and shared memory for caching.

    eaccelerator.compress
        Enables or disables cached content compression. Default value is  "1"  that
        means enable compression.

    eaccelerator.compress_level
        Compression level used for content caching.  Default value is "9" which  is
        the maximum value

    eaccelerator.name_space
        A string that's prepended to all keys. This allows two applications that
        use the same key names to run on the same host by setting this in .htaccess
        or in the main configuration file for the whole webserver.
       
    eaccelerator.keys
    eaccelerator.sessions
    eaccelerator.content
        Determine where keys, session data and content will be cached. The possible
        values are:
        "shm_and_disk" - cache data in shared memory and on disk (default value)
        "shm"          - cache data in shared memory or on disk if shared memory
                         is full or data size greater then "eaccelerator.shm_max"
        "shm_only"     - cache data in shared memory
        "disk_only"    - cache data on disk
        "none"         - don't cache data

    eaccelerator.allowed_admin_path
        The script paths that are allowed to get admin information and do admin
        controls

    Control panel and disassembler
    ------------------------------

    If you want to use the control-panel you need to compile eAccelerator with
        --with-eaccelerator-info which is the default value.
    You need to copy the control.php file to your webroot and set the path to it
    in the php.ini or eaccelerator.ini in the eaccelerator.allowed_admin_path
    directive. If you don't do this you wont be able to see much information and
    can't control eAccelerator.
    You can set the username and password needed to access the control-panel in
    the control.php file.

    When you compile eAccelerator with --with-eaccelerator-disassembler you need
    to place the dasm.php and PHP_Highlight.php file also in the same directory
    as the control.php file. The disassembler requires PHP to be compiled with
    tokenizer support (--enable-tokenizer).
    You can set the username and password needed to access the disassembler at the
    top of dasm.php.

    eAccelerator API
    ----------------

    API documentation can be found on this website: http://bart.eaccelerator.net/doc/phpdoc/

    Contact us
    ----------
    You can contact us with questions, patches or bugs, by sending an email to
    Bart Vanbrabant

    展开全文  
    收起全文  
    php的异常处理基础学习 (PHP心得)
    发布于 2007-09-09 18:33 2 阅读:10,011 评论:2 标签: php 学习 异常

      一直以来对PHP5没怎么好好学习,属于那种用着的时候,查手册Google资料的那种人。前天看见同事的程序满眼的try,throw,catch,立马汗颜。不禁为自己在这方面的知识深深自责一下

      今天挤出点时间学习了这个东西。参考了一下文档:
      1:PHP 15:异常
      2:用实例分析PHP5异常处理,一看就懂
      3:PHP 5.0异常处理机制深度探索
      4:PHP5的异常处理机制

      PHP5内建的异常类需要有以下成员方法:

    __construct() 构造函数,需要一个出错信息和一个可选的整型错误标记作参数
    getMessage() 取得出错信息
    getCode()
    出错的代码
    getFile() 异常发生的文件
    getLine() 异常发生的行数
    getTrace() 跟踪异常每一步传递的路线,存入数组,返回该数组
    getTraceAsString()

    和getTrace()功能一样,但可以将数组中的元素转成字符串并按一定格式输出

     __toString()  允许简单的显示Exception对象,并且给出所有以上方法给出的信息。

      Haohappy有几句话说的很好,PHP的异常机制可以满足我们如下的4点需求:

    以下是引用片段:

    1.允许一个方法给出一个出错标记给客户代码
    2.提供程序错误的详细信息
    3.让你同时判断多个出错条件,将你的错误报告和程序处理流程分开。
    4.返回值必须是独立的类型,不会与正常返回的类型相混淆

      写了点程序练习一下:

    以下是代码片段:

    $a = 20;

    // 使用常规catch的例子
    try
    {
      if($a == 1)
      {
        throw new Exception("I am 1", 1);
      }
      elseif ($a == 2)
      {
        throw new Exception("I am 2", 3);
      }
      elseif ($a == 3)
      {
        throw new Exception("I am 3", 3);
      }
      elseif ($a == 4)
      {
        throw new Exception("I am 4", 4);
      }
      else
      {
        throw new Exception("Who am I ?", 0);
      }
    }
    catch (Exception $e)
    {
      if($e->getCode() == 1)
      {
        echo "1 : ".$e;
      }
      elseif ($e->getCode() == 2)
      {
        echo "2 : ".$e;
      }
      elseif ($e->getCode() == 3)
      {
        echo "3 : ".$e;
      }
      elseif ($e->getCode() == 4)
      {
        echo "4 : ".$e;
      }
      else
      {
        echo "0 : ".$e;
      }
    }

    echo "


    ";

    // 使用不同的扩展异常类的例子
    class A extends Exception{};
    class B extends Exception{};

    try
    {
     if($a == 1)
      {
        throw new A("I am A", 1);
      }
      elseif ($a == 2)
      {
        throw new B("I am B", 2);
      }
      else
      {
        throw new Exception("Who am I ?", 0);
      }
    }
    catch (A $e)
    {
      echo "1 : ".$e;
    }
    catch (B $e)
    {
      echo "2 : ".$e;
    }
    catch (Exception $e)
    {
      echo "0 : ".$e;
    }

    ?>

      输出如下:

    以下是引用片段:

    0 : exception 'Exception' with message 'Who am I ?' in D:\WebPHP\WWW\new\test.php:24 Stack trace: #0 {main}


    0 : exception 'Exception' with message 'Who am I ?' in D:\WebPHP\WWW\new\test.php:69 Stack trace: #0 {main}

    展开全文  
    收起全文  
    PHP中位数不一样的数字的位操作 (PHP心得)
    发布于 2007-04-16 17:12 8 阅读:44,826 评论:8 标签: php 位操作

    一直以来对算法性的东西了解的少,这不今天又遇见问题。看google黑板报一个数学之美的文章简单之美:布尔代数和搜索引擎的索引,觉得对二进制的运算练习很少,于是拿来练手。

    当位数不一样时运行的结果已然不是1和0的组合了

    例如:

    CODE:
    $a 1001;
    $b 111000;

    $c $a $b ;
    $d $a $b ;
    $e $a $b ;
    echo 
    $c." ".$d." ".$e;
    ?>

    结果是 :392 111609 111217

    不明白其中的道理,转而向喜悦村求救。得到fly512给的答案:

    CODE:
    $a  1001;
    $a1 base_convert$a102) ;        //把10进制转化为2进制
    $b  111000;
    $b1 base_convert$b102);       //把10进制转化为2进制
    $c $a $b ;

    echo 
    $c.'
    '
    ;//十进制结果
    echo base_convert$c102); //把$c转化为2进制
    echo $a1." ".$b1."
    "
    ;
    /******************
    00000001111101001   //$a1的值,也就是$a的2进制,高位加0,与$b的2进制对齐
    11011000110011000   //$b1的值,也就是$b的2进制
    00000000110001000  //相与的结果,全1则为1,否则为0
    ********************/
    ?>
    不由得为自己的函数知识感到惭愧。。。。。
    展开全文  
    收起全文  
    PHP5时区问题 (PHP心得)
    发布于 2007-02-28 17:42 4 阅读:13,307 评论:4 标签: php 时区

    今天在PHP5下用date("H:i:s")时,发现参数"H"取出的时间与window下的时间不对。查了一下资料,发现是PHP5的php.ini里面默认设置为:

    [Date]
    ; Defines the default timezone used by the date functions
    ;date.timezone =

    如此一来,按照默认的时间便为GMT时间。而我们一般是使用北京时间,可以设置为:date.timezone = Asia/Shanghai。即:

    [Date]
    ; Defines the default timezone used by the date functions
    date.timezone = Asia/Shanghai

    记得不要设置为"Asia/Beijing",老外好象对上海感兴趣点,呵呵。

    如果没有权限改php.ini,可以用函数date_default_timezone_set('Asia/Shanghai');

    这个函数用于设定所有日期时间函数的默认时区。手册上如此说明:“自 PHP 5.1.0 起(此版本日期时间函数被重写了),如果时区不合法则每个对日期时间函数的调用都会产生一条 E_NOTICE 级别的错误信息”。但是“本函数永远返回 TRUE(即使 timezone_identifier 参数不合法)。”

    在此再学习一下函数:string date_default_timezone_get ( void )。这个函数的目的是取得一个脚本中所有日期时间函数所使用的默认时区。

    这个函数的返回值遵循以下顺序:1:用 date_default_timezone_set() 函数设定的时区(如果设定了的话)。2:TZ 环境变量(如果非空)。3:date.timezone 配置选项(如果设定了的话)。4:自己推测(如果操作系统支持)。5:如果以上选择都不成功,则返回 UTC

    再深入学习一下什么是UTC:
    协调世界时(UTC):
    一种称为协调世界时的折衷时标于1972年面世。为了确保协调世界时与世界时(UT1)相差不会超过0.9秒,有需要时便会在协调世界时内加上正或负闰秒。因此协调世界时与国际原子时(TAI)之间会出现若干整数秒的差别。位于巴黎的国际地球自转事务中央局(IERS)负责决定何时加入闰秒。

    UTC = Coordinated Universal Time. 中文名称为协调世界时.

    GMT = Greenwich Mean Time. 中文名称为格林尼治(平)时(这里的"w"是不发音的,而且"Green"要读成"Gren")

    UTC = GMT +/- 0.9 s
    因此 UTC 间中需要进行 "闰秒" 以控制两者相差。

    但是TZ 环境变量呢?还没找到详细的资料......

    附参考资料:
    1:请问在windows下安装Apache服务器的时间怎么调整?
    2:什么是GMT,什么是UTC
    3:谁能详细解释一下UTC和GMT

    展开全文  
    收起全文  
    浅谈PHP生成静态页的两种方法 (PHP心得)
    发布于 2006-12-27 13:31 5 阅读:12,508 评论:5 标签: php 方法 静态

    最近作的一个项目中用到了两种用PHP生成静态页面的方法,回想起当初自己还不知道如何生成静态页面的迷惘,以及看不懂高手写的文章的痛苦,觉得自己有必要站出来为还不知道如何生成静态页的phper写一个通俗点文章,以帮助他们尽快掌握这个好东西。

    在我之前所见的文章中要不是用代码堆砌空间就是用高手与高手交流用的语言让新人望而生却。因此本文尽量把整体思路说得详尽点。

    两种方法简单说明如下:
    1. 使用文件函数得到静态页面的模板字符串,然后用str_replace函数将需要替换的东西替换了再写入到新的文件中。
    2. 利用PHP的输出控制函数(Output Control)得到静态页面字符串,再写入到新的文件中。

    下面开始详细的说明。

    一. 利用模板生成

    什么是模板?如果大家使用过Dreamwerver中的“另存为模板”就应该知道模板是用来统一风格的东西。它只让你修改页面的某一部分,当然这“某一部分”是由你来确定的。本文在这说的模板也就是这个意思。(此外,PHP模板技术还包括phplib、smarty等等,这不是本文所说内容了)

    把模板的概念结合本文再说得具体一点就是:美工先做好一个页面,然后我们把这个页面当作模板(要注意的是这个模板就没必要使用EditRegion3这样的代码了,这种代码是Dreamwerver为了方便自己设计而弄的标识),把这个模板中我们需要改变的地方用一个与HTML可以区分的字符代替,如“{title}”、“[title]”。在生成静态页面的时候只需要把数据和这些字符串替换即可。这就是模板的含义了。

    下面来说一下具体的实现思路:做一个模板

    展开全文  
    收起全文  
    芽雨配置php服务器手记 (PHP心得)
    发布于 2006-09-15 12:41 4 阅读:13,412 评论:4 标签: php 服务器 配置

    我安装这个服务器,参照了三个人的文章,如下:非常感谢他们

    吟清PHP学习之路第二步 - 安装配置PHP运行环境!
    http://www.aspid.cn/blog/article.asp?id=305

    如何安装配置phpMyAdmin进行数据库的管理http://blog.wenxue.li/archives/?article-46.html

    安装php mysql apache
    http://nonoroom.spaces.live.com/blog/cns!5AAD7F8C6C6BEF96!110.entry


    软件下载地址:

    Apache 2.0.58 for Windows:   http://www.onlinedown.net/soft/11528.htm
    PHP 4.4.2 :
    http://www.onlinedown.net/soft/1774.htm
    phpMyAdmin 2.8.2:            http://www.onlinedown.net/soft/2622.htm
    Zend Optimizer 2.5.7:        http://www.onlinedown.net/soft/32228.htm
    MYSQL For Windows V4.1.20:   http://www2.skycn.com/soft/24418.html

    PHP 5.1.4        http://www.onlinedown.net/soft/1772.htm
    MYSQL 5.1.11 beta   http://www.onlinedown.net/soft/3575.htm

    在芽雨的安装中,目录是这样的,根目录为D:\WebPHP。下面分:PHP,Apache2,MySQL,WWW。他们分别放置PHP系统文件,Apache2系统文件,MySQL系统文件,网站程序。

    安装mysql-4.1.20-win32:

        选择Custom安装。目的是安装在自己设置的目录。
        在选择安装目录中,设置为:D:\WebPHP\MySQL
        在“MySQL.com Sign-up”中,我选择的是“Skip Sign-Up”
        在“Please select the default character set”中,偶选择的是第三种,并在“character set”中选择“gb2312”
        在设置密码时,偶还选择了“enable root access from remote machines”。意思大概是允许远程管理数据库吧。
        装好以后,我们来检验一下安装好了没有。
        开始--运行--cmd:我们进入DOS下。进入D:\WebPHP\MySQL\bin目录。
        输入进入数据库的命令:mysql -hlocalhost -uroot -yayu。解释一下:-h后为主机地址,-u后面为管理员帐号,-p后为密码。这个命令很好记的。h是host,u是user,p是password。
        好了,芽雨已经进去了。我们再看看默认的数据库有没有。运行:show databases;。记得命令后有分号!
        好,现在我已经看见系统显示了两个数据库:mysql和test。OK!芽雨成功了

    安装apache_2.0.58-win32-x86-no_ssl.msi

        在“server information”中,芽雨不知道那是什么意思。就写上了我的网站和Email。
        选择Custom安装。目的和上面一样,是为了安装在自己设置的目录。
        在选择安装目录中,设置为:D:\WebPHP\。请注意,我在这没有在后面加“Apache\”,因为只有这样,"Apache2"才会成为WebPHP下的第一级子目录。
        安装完了,你会发现右下角多了一个图标,那是Apache的服务标志!
        这时你在IE中输入“http://localhost/”或者“http://127.0.0.1”。如果出现了Apache的提示成功的页面,那你就成功了!

    安装php-4.4.2-Win32

        解压php-4.4.2-Win32.zip,把里面的php-4.4.2-Win32文件夹复制到D:\WebPHP\目录里,并改名为:PHP。
      请将“D:\WebPHP\PHP\php4ts.dll”移入D:\WebPHP\PHP\sapi”。最后将“D:\WebPHP\PHP\php.ini-dist”改名为“php.ini”后移到 Apache2 的安装目录“D:\WebPHP\Apache2”下(注意:移到系统目录例如 C:\WINNT亦可,但这样重装系统后你又得重新配置PHP,这种移到Apache2目录的方法可以省去该麻烦)。
      最后,在 D:\WebPHP\php 下新建两个子目录“session”和“includes”(理由?呵呵,别急,下面会说明)

    Apache及PHP的配置

      配置PHP的一些属性:打开“D:\WebPHP\Apache2\php.ini”。以下操作在此进行。

         1:配置PHP服务的文件夹(PHP文件放置的根目录),既你以后的程序都放在这里面以让IE能访问它。搜索“doc_root”。另它等于为:“doc_root = D:/WebPHP/WWW”。注意请使用斜杠"/"而非反斜杠"\"。下同!
         2:配置配置动态函数的路径,即PHP的扩展模块。搜索“extension_dir”,把它改为:“extension_dir = "D:/WebPHP/PHP/extensions"”。这时你搜索一下:“;extension=”,你将看见很多的东西,那都是PHP的扩张模块,当你需要的时候只要把前面的“;”去掉就可以了!
         3:配置定义 session 储存资料的文件路径。搜索“session.save_path”,会看见:“;session.save_path = /tmp”。前面有“;”,说明它没有被起用。这个问题在很多教程中都没有提到,而且一般SESSION在身份验证、购物车等时候才需要,所以初学者容易忽视。好,现在我们把它改为:“session.save_path = D:/WebPHP/PHP/session”。注意前面没有“;”了哈!
        4, 这个版本MySQL的加密算法变了,链接数据库明明输入了正确的密码还是出现
    MySQL #1251 Error 错误:
    Client does not support authentication protocol requested by server. Consider upgrading MySQL client

    比如这段程序,可以用来检测数据库是否连接成功,运行会出现错误!

    $link=mysql_connect('localhost','root','123');
    if(!$link) echo "MySQL 数据库连接失败";
    else echo "MySQL 数据库连接成功!";
    mysql_close();
    ?>

    吟清在Google找到解决方法:

    mysql> SET PASSWORD FOR
    -> ' some_user '@' some_host ' = OLD_PASSWORD(' newpwd ');

    结合我们的实际情况,在 MySQL Command Line Client 下运行:

    set password for root@localhost = old_password('123');

      配置Web服务器Apache

         1:依次展开“开始菜单==>程序==>Apache HTTP Server 2.0.48==>Configure Apache Server==>Edit the Apache httpd.conf Configuration File”,打开Apache的配置文件“httpd.conf”。或者直接在D:\WebPHP\Apache2\conf中打开httpd.conf。
         2:搜索“#Listen”,找到“#Listen 12.34.56.78:80”一行,如果想让Apache2只监听某一该IP段,这里就需要去掉注释,改成你需要的IP地址。例如,你只需要本机调试,不想让外部访问,那就改成 “Listen 127.0.0.1:80”,这样一来,只能从你本机访问(地址栏输入 127.0.0.1 或者 localhost)才能看到Apache2的页面。或者当你网卡绑定了两个以上的IPe而只想用其中某一个时也可以考虑用这个方法。一般而言不必对此做太多修改。
         3:搜索“#LoadModule”,会看见一大串连续的行。这些是Apache2为了解释特定的语言而引入的模块。请在后面加入新的一行:“LoadModule php4_module D:/WebPHP/PHP/sapi/php4apache2.dll”以使Apache2加入对PHP的支持。
        4:然后在这一行的后面再加上(其实加在哪里都一样,这样只是为了便于以后纠错):
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php .php4
        AddType application/x-httpd-php .php3
        AddType application/x-httpd-php .phtml
        AddType application/x-httpd-php-source .phps

        
      上述几行的用处是添加Apache支持和解释的PHP后缀名。您一定可以想到,如果加入“AddType application/x-httpd-php .html”一行,那么直接把PHP文件存为html格式也不要紧,你的Apache还是会自己解释的。
       (如果使用的是Apache1.x版本,还需做以下操作:搜索“AddModule”,还是找到一大串的连续行。在最后一行的下面加上“AddModule mod_php4.c”一行。本文使用的是2.x系列,所以毋需此步骤。)
        5:修改默认的Apache所服务的文件夹,这里需要修改两个地方。
        搜索:“DocumentRoot”,找到:“DocumentRoot "D:/WebPHP/Apache2/htdocs"”,这里的目录是随你安装的地址不同而不同的。把它改为:“DocumentRoot "D:/WebPHP/WWW"”。然后在往下找找:“”这里也需要需要修改,显然,它应该为:“<Directory "D:/WebPHP/WWW">”。如果你还记得上面修改php.ini的情形,那你现在应该知道:如果要更换根目录,那么你需要修改三个地方!
        6:增加虚拟目录。如果需要增加虚拟目录,请添加类似“ Alias /manual "D:/WebPHP/Apache2/htdocs/manual/" ”的行。其中“Alians”后面的那个斜杠后面对应的是虚拟目录名,后面的是它的物理路径。上面的地址就可以通过“http://127.0.0.1/manual”来访问。
        7:自定义默认首页。查找 DirectoryIndex index.html index.html.var 在后面加入 index.htm index.php


       更改环境变量

      由于PHP在windows下运行时需要一些额外的DLL,所以需要用到“D:\WebPHP\PHP\dlls”下的那些文件。常规方法是将这些文件放到“C:\WINDOWS\system32”下,但这样一来每次重新装都要如此,所以我使用环境变量来避免此问题。桌面右击“我的电脑”==>“属性”==>“高级”==>“环境变量”==>“系统变量”==>找到“Path”一行,双击,在后面添加上述目录,注意记得在原先的环境变量后面加上分号以区分(即需要输入“;D:\WebPHP\PHP\dlls”)
       来,我们来看看我们现在的PHP环境变量。在一个php文件中写如下语句:

    phpinfo();
    ?>

       然后打开它,你是不是可以看见了一个页面?这个页面芽雨也不是很懂,汗~~~

     

    安装phpMyAdmin-2.8.2.zip 
     
         解压它,把里面的phpMyAdmin-2.8.2文件夹移动到D:\WebPHP\WWW。并改名为:“phpMyAdmin”。
         打开D:\WebPHP\WWW\phpMyAdmin\libraries里面的config.default.php。我们。来修改一下它。 
       
         1。设置站点。搜索“$cfg['PmaAbsoluteUri']”,把它设置为:“$cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin/';”
         2:登陆phpMyAdmin时的设置
            $cfg['Servers'][$i]['auth_type']     = 'cookie';   
            $cfg['Servers'][$i]['user']          = 'root';     
            $cfg['Servers'][$i]['password']      = 'yayu'; 
    config: 按照 自身 libraries/config.default.php 文件中的配置提供用户名和密码
    cookie:用于输入口令方式登陆,如果选择此项,需要设置$cfg['blowfish_secret'] = 'cookie';(见后面的介绍)    

         3,“$cfg['DefaultLang'] =”一行后面是它默认的语言,这里我们将它改为“$cfg['DefaultLang'] = 'zh';”,顺便把下面10行左右的默认字符集“$cfg['DefaultCharset'] =”改为“$cfg['DefaultCharset'] = 'gb2312';”。

     

    现在我们进入http://localhost/phpmyadmin/index.php。发现要登陆两次才进得去,原因未知。进入后,发现全是乱码!没关系,这可以改。把Language选项改为:“中文 - Chinese simplified”,再把“MySQL 连接校对”改为“gb2312_chinese_ci”,好了,中文出来了。以后在进行数据库操作的时候,如果发现有字符集的选项,和上面一样弄就可以了!


     补充:

    如果出现“配置文件现在需要绝密的短语密码(blowfish_secret)”
    那么请在$cfg['blowfish_secret'] = ' ';的等号里面设置你网站的cookie,例如:$cfg['blowfish_secret'] = 'www.taoliyuan.com.cn';
    这是因为你的“$cfg['Servers'][$i]['auth_type'] = 'cookie'的原因。

     补充2:

    感谢blacksheep提出了两个笔误,他的个人网站是http://www.phpone.cn,一个很好的域名。

    展开全文  
    收起全文  
    关于我以前写的PHP新闻程序教程 (PHP心得)
    发布于 2006-07-19 23:24 1 阅读:12,031 评论:1 标签: PHP 教程 新闻

    大概是在2004年10月份,我写了一个PHP新闻程序教程,里面的东西是我根据自己的心得体会而写。想法源于自己在学了一半C语言后初次接触PHP的困惑。想必大家都知道,在大学我们所接触到的C语言无非就是用另一种语言在描述小学或初中数学。令人感觉枯燥而无味!丝毫感觉不到计算机程序在我们生活中扮养这着什么样的角色!

    而,PHP让我看见了希望,我终于明白程序可以用来做什么了,它可以让事情朝着自己想的方向变化。就好象自己就是上帝一样!天!这是一种什么样的感觉!

    从困惑到感觉有希望,是有过程的。我不是什么人才,可以坦率的说,从C到PHP的过程我困惑了很久。我就不明白,程序为什么要这么写?语句怎么就能这么用呢?(芽雨是不是很笨?)说到底,这还是一个算法的问题。课堂上的C语言没有涉及到网络编程的算法。

    所以,当我自己会做一个简单点的新闻系统时,我就有一种想宣泄的情绪。于是我就拿起了笔,看着书,看着手册,根据自己的体会写了一个教程。

    教程发布以后,也帮助过几个人。尤其是这几天,我的邮箱里面收到2个人求援信,QQ上也竟然有人加我谈这个教程。真令我汗颜......

    也由此我得知,呤清网友根据我给的程序重新整理了一下。并且在他blog发布了。在这里不想夺人之美把他整理的程序往我这里放。请大家去他发布的地方看:吟清PHP学习之路第五步 - 基础新闻教程

    借今天有心情写blog的机会,我重新贴一下这个教程,在本站的BBS[PHP心得]版面。欢迎查看!

    展开全文  
    收起全文