使用Pear::Pager类的一个问题

今天把公司的服务器从php4升级到php5,问题来了.最严重的是使用Pear::Pager类,报错如下:
Fatal error: Cannot re-assign $this in D:xampphtdocstmptest.php on line 5

看了下Pager类的构造,有如下代码:
$this = ……………..;

看来从php5开始不再支持这种对自身重新实例化的写法了,只好重写了Pager类草草收场

[@more@]

升级到php5的日记 一

终于要从php4升级到php5了,是的,俺费尽了口舌,说服了boss使用php5和mysqli开发新项目.

首先俺细细的阅读了官方站点上介绍php5的有关章节,以及网络上的一些关于php5的文章.基本开发环境定为linux+apache2+php5+mysql4.1,很经典的搭配.为了提高开发效率,俺决定继续使用pear的类库和prado,因此现状是php4,php5的代码将并存.第一周俺们就遇到了麻烦:

1.mysqli和zend1的兼容性
php.ini里面有一个选项,可以开启对zend1的兼容性,如果你在打开这个开关的同时还想使用mysqli的话,很快就会失望.它会无情的告诉你:
unable clone a uncloneable object…………………

2.使用prado和php5的一些问题
prado程序包prado.php的有段代码如下:
set_error_handler( …….. );
php5的配置默认是不提示E_STRICT级别的错误,要命的是,这行代码对任何错误都会die(………………..),pear的代码完全没办法工作,只好咔嚓之

大文件上传且带进度条的php解决方案

以下是用Pear::HTML_Progress实现大文件上传的例子

  • HTTP 1 – Upload files with your web browser to a web server. Single page (using frames).
  • HTTP 2 – Upload files with your web browser to a web server. Progress meter in a popup.
  • HTTP 3 – Mixed field Upload. Single page (using frames).
  • HTTP 4 – Upload files with your web browser to a web server and logs operations into a file.
  • FTP – Upload file on a remote ftp server that may be different than webserver.

    更多的HTML_Progress教程看这里:
    http://pear.laurent-laville.org/HTML_Progress/examples/

  • [@more@]

    PHPObject 1.44 released

    PHPObject 1.44早在这个月的15日就发布了,但是俺对这东东一直很欠感冒,因为它和AMFPHP一样对多字节的文字支持很差,可以说无法使用。

    今天看到超链接地址AMFPHP的中文使用办法 这篇文章受到了启发,在PHPObject中用同样的办法,果然也可以正常显示中文。

    测试时,这两个东东可以不加(也不能加):

    System.useCodepage=true;

    myFoo.utf8encode(false);

    下载超链接地址PHPObject 1.44

    php代码美化程序PHP_Beautifier试用手记

    在pear的rss列表上看到了PHP_Beautifier 0.1.1 beta发布,便下载回来试用:
    >>pear install PHP_Beautifier
    ………………………………………..

    顺利完成,看了下帮助,还带有命令行工具,方便:

    D:xamppphp>php_beautifier –help

    Usage: php_beautifier [options]
    and/or can be ‘-‘, which means stdin/stdout.
    you can use ? and * for batch processing
    can be a dir (ending with ‘/’ or a real dir)
    or a file (without ‘/’)
    multiple ins and one out = merge all files in one output
    Options:
    –input or -f input file – default: stdin
    –output or -o output dir or file – default: stdout
    –indent_tabs or -t indent with tabs
    –indent_spaces or -s indent with spaces – default
    –filters or -l Add filter(s)
    –directory_filters or -d Include dirs for filters
    –compress or -c Compress output
    –recursive or -r Search in subdir recursively
    –help or -? display help/usage (this message)

    Filter definition:
    –filters "Filter1(setting1=value1,setting2=’value2′) Filter2()"

    不过试用下来,处理的不是太完美,比如复杂点php代码美化后不整齐之类的,期待更好的版本出现 [@more@]

    更好的将editplus与phpCodeBeautifier结合使用

    phpCodeBeautifier这款php代码美化工具已经很久不见更新,它的命令行版本似乎有些bug,不能正确的将php代码弄的很整齐。但是phpCodeBeautifier的GUI版本还是能够执行正确无误的,可惜无法直接在命令行模式下打开某个文件,想与editplus结合使用比较困难。

    但是注意到phpCodeBeautifier总是会打开上一次使用过的文件,打开phpCodeBeautifier.ini一看,LastFile=’******’不正是我们需要的东东么?

    于是俺写了如下批处理文件搞定这个问题:

    代码片段:

    
    set phpcb_path="F:Program FilesphpCB
    set phpcb_ini=%phpcb_path%phpCodeBeautifier.ini"
    echo [Settings]        >%phpcb_ini%
    echo LastFile=%1    >>%phpcb_ini%
    echo [MainForm]        >>%phpcb_ini%
    echo Left=-4        >>%phpcb_ini%
    echo Width=1032        >>%phpcb_ini%
    echo Top=-4        >>%phpcb_ini%
    echo Height=748        >>%phpcb_ini%
    echo [Options]        >>%phpcb_ini%
    echo FileFormat=0    >>%phpcb_ini%
    echo Settings=PEAR    >>%phpcb_ini%

    %phpcb_path%phpCodeBeautifier.exe

    在editplus的工具配置中调用以上批处理文件,参数为$(FilePath),一切搞定,可以用phpCodeBeautifier自动打开editplus当前编辑的文件:P

    PRADO v2.0RC发布

    PRADO v2.0RC发布,还不是稳定版本,但是可以尝试一下.更新如下:

    [@more@]

    – Added I18N, L10N support (with several relevant components)
    – Added TDataGrid, TTable, TDataList, TWizard, TRequiredListValidator controls
    – Implemented viewstate manager handler
    – Implemented enumerable property type
    – Changed the way of including a parameter file within another one
    – Added EncodeText property to controls with Text property
    – The parameter of TComponent::removeChild() is changed to component from ID
    – Control state synchronization is done in addBody() now (instead of addChild())
    – Control viewstate maintenance is now based on container-containee relationship
    – TComponent::addParsedObject() is now invoked when parsing an object
    – List control now renders values instead of indexes
    – Implemented TCollection class, Bodies property of TControl
    is now of type TCollection that allows insertion
    – Added Datalist, Datagrid and I18N examples
    – Implemented feature 1093392: Better package layout
    – Implemented feature 1094956: display spaces
    – Implemented feature 1102525: Module spec file
    – Fixed bug 1093843: TRepeater::getItemCount() returns wrong value
    – Fixed bug 1094219: TDateFormat patterns missing
    – Fixed bug 1093018: Translation table cache and php open tag
    – Fixed bug 1091966: Error handler doesn’t make allowances for @ operator
    – Fixed bug 1100512: Controls losing viewstate
    – Fixed bug 1103937: TListControl fatal error within TDataList
    – Fixed bug 1099808: TTextBox: Slashes won’t be stripped
    – Fixed visibility bug related with selection controls

    在psftp中进行批处理操作

    在psftp(sftp的命令行客户端)中进行批处理操作:

    1.首先建立文件->myscript.scr,内容如下:

    代码片段:

    
    cd /home/ftp/users/jeff
    del jam-old.tar.gz
    ren jam.tar.gz jam-old.tar.gz
    put jam.tar.gz
    chmod a+r jam.tar.gz
    quit

    2.然后你可以运行下面命令行:

    psftp user@hostname -b myscript.scr

    myscript.scr中所写的内容就会执行下去

    3.有什么用呢?在windows下写个批处理.bat,配合editplus上传文件,爽翻你

    附命令行帮助:

    代码片段:

    
    PuTTY Secure File Transfer (SFTP) client
    Release 0.56
    Usage: psftp [options] [user@]host
    Options:
      -b file   use specified batchfile
      -bc       output batchfile commands
      -be       don't stop batchfile processing if errors
      -v        show verbose messages
      -load sessname  Load settings from saved session
      -l user   connect with specified username
      -P port   connect to specified port
      -pw passw login with specified password
      -1 -2     force use of particular SSH protocol version
      -C        enable compression
      -i key    private key file for authentication
      -batch    disable all interactive prompts
      -V        print version information