Warning: session_start()的解决方法
修改php.ini中的session.auto_start = 0 为 session.auto_start = 1
字符串运算符. <?php $a=my; $b=name; echo ($a.$b); #把字符串$a与字符串$b连起来 ?>
数组运算符+
+ 运算符把右边的数组附加到左边的数组后面,但是重复的键值不会被覆盖。
<?php
$a = array("a" => "apple", "b" => "banana");
$b = array("a" => "pear", "b" => "strawberry", "c" => "cherry");
$c = $a + $b; // Union of $a and $b
echo "Union of \$a and \$b: \n";
var_dump($c);
$c = $b + $a; // Union of $b and $a
echo "Union of \$b and \$a: \n";
var_dump($c);
?>
因为PHP需要定制,所以yum安装个人认为比较麻烦,所以跟据自己使用需要用源码包安装
从http://www.php.net下载PHP PHP4还是PHP5根据软件需要下载
以下使用PHP 5.2.5 Released安装 tar -jxvf php-5.2.5.tar.bz2 cd php-5.2.5 ./configure --with-apxs2=/usr/local/apache2/bin/apxs \ --enable-mbstring --with-zlib --with-gd \ --with-jpeg-dir=/usr/local/lib --with-png-dir \ --with-mysql --with-mcrypt --with-xsl --with-gettext\ --with-mysql-sock --with-ldap --with-mhash \ --with-imap --with-kerberos --with-imap-ssl 安装时所需支持依赖包,可以通过yum安装 make && make install cp php.ini-dist /usr/local/lib/php.ini 安装后可以通过下面的代码测试PHP显示的相关信息 <?php phpinfo(); ?>
支持Mysql Postgres数据库
./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable-mbstring --with-zlib --with-gd --with-jpeg-dir --with-png-dir --with-mysql=/usr/local/mysql --with-pgsql
This site has the repositories that will upgrade your PHP 5.1 to 5.2 nano -w /etc/yum.repos.d/utterramblings.repo ... and then paste the following into the editor: [utterramblings] name=Jason's Utter Ramblings Repo baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka NOTE: If the above URL returns a 404 then try hard-coding $releasever to your EL version ('EL4' or 'EL5') and the $basearch to whatever is appropriate ('i386' or 'x86_64'). For those new to linux, the nano command is for a linux editor, and once you type the 6 lines, press ctrl O to write the file and press enter to save to the file name given. Once you've taken care of the above, you'll be able to easily upgrade with a simple 'up2date -u' or 'yum update'. If you get dependency errors, if you do 'yum update', you might want to try just the php update by trying 'yum - y php update'. Updating: php x86_64 5.2.6-jason.1 utterramblings 3.9 M php-cli x86_64 5.2.6-jason.1 utterramblings 2.7 M php-common x86_64 5.2.6-jason.1 utterramblings 494 k Updating for dependencies: php-devel x86_64 5.2.6-jason.1 utterramblings 568 k php-gd x86_64 5.2.6-jason.1 utterramblings 342 k php-imap x86_64 5.2.6-jason.1 utterramblings 112 k php-ldap x86_64 5.2.6-jason.1 utterramblings 61 k php-mbstring x86_64 5.2.6-jason.1 utterramblings 1.3 M php-mysql x86_64 5.2.6-jason.1 utterramblings 275 k php-odbc x86_64 5.2.6-jason.1 utterramblings 120 k php-pdo x86_64 5.2.6-jason.1 utterramblings 166 k php-xml x86_64 5.2.6-jason.1 utterramblings 336 k php-xmlrpc x86_64 5.2.6-jason.1 utterramblings 135 k after the initial php and its dependencies are updated you can update the rest. #yum –y update –gets errors to install the list below…so just yum install each separately. eg: #yum -y apr apr-util update Updating: apr x86_64 1.2.12-2.jason.1 utterramblings 266 k apr-util x86_64 1.2.12-5.jason.1 utterramblings 166 k ed x86_64 0.2-39.el5_2 updates 49 k httpd x86_64 2.2.8-jason.3 utterramblings 2.6 M mod_perl x86_64 2.0.3-14.jason.1 utterramblings 5.5 M mysql x86_64 5.0.58-jason.2 utterramblings 6.5 M mysql-devel x86_64 5.0.58-jason.2 utterramblings 2.9 M mysql-server x86_64 5.0.58-jason.2 utterramblings 11 M pcre x86_64 7.6-jason.1 utterramblings 592 k php-pear noarch 1:1.6.2-1.jason.1 utterramblings 418 k