Different PHP versions behalves differently. The only two distribution on php.net is 4.4.4 and 5.2.0. The experience of the article describes class difference between 4.4.4 and 5.2.0 is that:
1). class members variable is decorated by "private" in 5.2.0, as "var" in 4.4.4
2). class functions is decorated by "public function" in 5.2.0, as "function" in 4.4.4
Several days ago, i wrote a php proxy for wap.roboo.com to transfer jsp response to a php server. And grabed a HTTPRequest class from google, the class code is as follows:
class HTTPRequest
{
var $_fp; // HTTP socket
var $_url; // full URL
var $_host; // HTTP host
var $_protocol; // protocol (HTTP/HTTPS)
var $_uri; // request URI
var $_port; // port
// scan url
function _scan_url()
{
....
}
// constructor
function HTTPRequest($url)
{
$this->_url = $url;
$this->_scan_url();
}
// download URL to string
function DownloadToString()
{
....
}
}
I use Slackware 11 to do most works, slack use php 4.4.4 by default. the HTTPRequest works ok on my machine. After deploy it on another fedora machine which has php 5.0 by default, it fails. Then I updated it to php 5.2.2, with the help of one colleague, I changed the class as follows to support 5.2.2:
class HTTPRequest
{
private $_fp; // HTTP socket
private $_url; // full URL
private $_host; // HTTP host
private $_protocol; // protocol (HTTP/HTTPS)
private $_uri; // request URI
private $_port; // port
// scan url
public function _scan_url()
{
....
}
// constructor
public function HTTPRequest($url)
{
$this->_url = $url;
$this->_scan_url();
}
// download URL to string
public function DownloadToString()
{
....
}
}
By the way, i use vi(vim actually) to edit source, just use :0,$s/var/private/g , :0,$s/function/public function/g to do the substitution.
After disabled SELinux on fedora , it works ok.
Utilize shell scripts,linux commands, open source tools,java, to Maximize the Power of Linux.
Focused on working with linux and shell, search engine technology including Chinese segmenter
Any questions please contact me at gmail: david.ullua
Labels
- working with linux (9)
- tools for developer (7)
- java (4)
- common tools (3)
- php (3)
- shell (3)
- linux (1)
- linux virtualization (1)
- mysql (1)
1/11/2007
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(24)
-
▼
January
(12)
- Mysql starting error: ... STOPPING server from pid...
- java knowledge tree
- 利用~/.netrc文件自动ftp下载文件 (当天或昨天的tomcat日志)
- KMail提示用户可能忘了附件的有趣功能
- use crontab and mail command to backup your firefo...
- send mail with attachment in command line
- add authentication for awstats in apache
- vim与gvim 转换highlight的文本到html网页
- Use eclipse with ant to deploy your java project -...
- Eclipse and gaim font settings under KDE
- to implement SVN password changing function by she...
- difference on class between php version 4.4.4 and ...
-
▼
January
(12)
About Me
- euler
- I am a senior developer and a team leader with 3 years development experience in Suzhou, China, focus on mobile web search, linux, Java and machine learning in NLP (natural language processing). My goal is to improve people's life with computer technology.
1 comment:
Wonderful article! We will be linking tto this particularly
great article on our site. Keepp up the great writing.
Also visit my web page :: cheapest car loan
Post a Comment