<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[php -a 交互式 0 === false???,PHP 的 Interactive shell 模式，Centos安装git并装Boris不用重新编译PHP实现类python命令行交互。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Wed, 26 Aug 2015 03:38:10 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	背景：有时PHP像python那样可交互能对小代码片段的验证提高效果，但默认编译好像是不行的。<br/>[root@localhost htdocs]# php -i &#124; grep readline<br/>[root@localhost htdocs]# 主要的差異在於 Compile 時, 有沒有加入 &quot;--with-readline&quot;,<br/><br/>试着安一个扩展：<br/>readline 相关错误<br/>现象：configure: error: Please reinstall libedit – I cannot find readline.h<br/>解决办法：安装 Editline Library (libedit)，官网：http://thrysoee.dk/editline/<br/>下载最新版 libedit 编译安装即可。<br/>直载后，直接：configure &amp;&amp;　make &amp;&amp; make install<br/><br/>正确安装如下：<br/>#php -a<br/>Interactive shell<br/><br/>php &gt; echo &quot;hello&quot; ;<br/>hello<br/><br/>不对的输出如下，输入 php -a 之后，基本就没有反应了。：<br/>#php -a<br/>Interactive mode enabled<br/><br/>解决方法：<br/>重新编译安装php，加入--with-readline选项。<br/>php -i &#124; grep &quot;&#92;-&#92;-with&#92;-readline&quot; --color<br/>不正确的输出是空，正确的输出编译项里有。<br/>_____________________________________________________________________________<br/> ./configure --with-readline<br/> configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.<br/><br/><br/> ./configure<br/> make &amp;&amp; make install<br/><br/> [root@iZ25dcp92ckZ readline]# make install<br/>Installing shared extensions:&nbsp;&nbsp;&nbsp;&nbsp; /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/<br/><br/>安上了，但还是失败了：<br/>[root@iZ25dcp92ckZ readline]# php -a<br/>php &gt; echo &quot;helo&quot;;<br/>php: symbol lookup error: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/readline.so: undefined symbol: append_history<br/><br/>这儿有一个兄弟也在问一样的问题，说是：php 的 readline 模块和所使用的 readline 库的版本差异太大了。<br/>摘自：http://segmentfault.com/q/1010000002455369<br/>——————————————————————————————————————————————————————<br/><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
$res=0;
if($res === false)&#123;
&nbsp;&nbsp;echo &#039;a&#039;;
&#125;else&#123;
&nbsp;&nbsp;echo &#039;b&#039;;
&#125;
</textarea><br/><br/>0 === false???<br/><br/>php &gt; var_dump( 0 === false);<br/>bool(false)<br/>php &gt; $res =0;<br/>php &gt; var_dump( $res === false);<br/>bool(false)<br/><br/><br/><br/>php -a<br/>Interactive mode enabled<br/><br/>&lt;?php<br/>echo time() . &quot;&#92;n&quot;;<br/>$a = 1;<br/>echo $a;<br/>?&gt; Ctrl + d<br/>1440560402<br/>1<br/><br/><br/><br/><br/><br/>————————————————————————————————————————————————————<br/>臨時要測個簡單的程式片段 或 Function, 一般都會於 CLI 寫來跑一跑, Interactive 模式 可以邊寫邊測試~ (互動模式, 寫完一行就 Compile 一行)<br/><br/>而 PHP CLI 的模式有兩種差異: (執行方法: $ php -a, 說明可見: PHP: Interactive shell)<br/><br/>Interactive shell 比較像是 互動式, 有問有答的執行程式.<br/>Interactive mode enabled 則是輸入一整個區塊的程式碼, Ctrl-D 執行.<br/><br/>目前 (2012年) Ubuntu Linux 內建預設的是 Interactive shell, 而 Debian 是 Interactive mode enabled.<br/><br/>主要的差異在於 Compile 時, 有沒有加入 &quot;--with-readline&quot;, 可使用 &quot;php -i &#124; grep readline&quot; 查看.<br/><br/>Interactive mode enabled<br/><br/>$ php -a<br/>Interactive mode enabled<br/><br/>&lt;?php<br/>echo time() . &quot;&#92;n&quot;;<br/>$a = 1;<br/>echo $a;<br/>?&gt; Ctrl + d<br/>1330954647<br/>1<br/><br/>Interactive shell<br/><br/>$ php -a<br/>Interactive shell<br/><br/>php &gt; echo time();<br/>1330954675<br/>php &gt; $a = 1;<br/>php &gt; echo $a;<br/>1<br/><br/>来自：http://blog.longwin.com.tw/2012/03/php-interactive-shell-2012/<br/>解决办法就是重新编译并安装一次加上参数：<br/>http://blog.csdn.net/pqhdp/article/details/9386185<br/><br/><br/><br/>在php Interactive mode里敲代码不需要&lt;?php ?&gt;的啊，直接输入echo &quot;hello&quot;; 回车就可以了。<br/>还有php现在有一个还不错的repl实现<br/>https://github.com/borisrepl/boris<br/>比 php -a 要更舒服一些。<br/><br/>演示：http://segmentfault.com/a/1190000000353069<br/>需要git。<br/><br/><br/>—————————Centos安装git并装Boris不用重新编译PHP实现类python命令行交互。—————————<br/>[root@localhost boris-1.0.10]# yum install git<br/>Loading &quot;fastestmirror&quot; plugin<br/>Loading mirror speeds from cached hostfile<br/> * base: 10.64.5.100<br/> * updates: 10.64.5.100<br/> * addons: 10.64.5.100<br/> * extras: 10.64.5.100<br/>base&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100% &#124;=========================&#124; 1.1 kB&nbsp;&nbsp;&nbsp;&nbsp;00:00&nbsp;&nbsp;&nbsp;&nbsp; <br/>updates&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 100% &#124;=========================&#124; 1.9 kB&nbsp;&nbsp;&nbsp;&nbsp;00:00&nbsp;&nbsp;&nbsp;&nbsp; <br/>primary.sqlite.bz2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100% &#124;=========================&#124; 504 kB&nbsp;&nbsp;&nbsp;&nbsp;00:00&nbsp;&nbsp;&nbsp;&nbsp; <br/>addons&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100% &#124;=========================&#124; 1.9 kB&nbsp;&nbsp;&nbsp;&nbsp;00:00&nbsp;&nbsp;&nbsp;&nbsp; <br/>extras&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;100% &#124;=========================&#124; 2.1 kB&nbsp;&nbsp;&nbsp;&nbsp;00:00&nbsp;&nbsp;&nbsp;&nbsp; <br/>Setting up Install Process<br/>Parsing package install arguments<br/>No package git available.<br/>Nothing to do<br/>[root@localhost boris-1.0.10]# cat /etc/redhat-release<br/>CentOS release 5.2 (Final)<br/>[root@localhost boris-1.0.10]# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm <br/>Retrieving http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm<br/>warning: /var/tmp/rpm-xfer.Q9d5Ba: Header V3 DSA signature: NOKEY, key ID 217521f6<br/>Preparing...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;########################################### [100%]<br/>&nbsp;&nbsp; 1:epel-release&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ########################################### [100%]<br/>[root@localhost boris-1.0.10]# yum install git&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>Loading &quot;fastestmirror&quot; plugin<br/>Loading mirror speeds from cached hostfile<br/><br/>yum install git<br/>Total download size: 7.5 M<br/>Is this ok [y/N]: y<br/>Downloading Packages:<br/>(1/4): git-1.8.2.1-1.el5.&nbsp;&nbsp;20% &#124;=====&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 1.5 MB&nbsp;&nbsp;&nbsp;&nbsp;00:12 ETA <br/><br/>安git参看：http://www.letuknowit.com/post/19.html，为何要安？是因为想用它安装PHP的Boris——PHP也有REPL。<br/>演示：http://segmentfault.com/a/1190000000353069&nbsp;&nbsp;<br/><br/>你可以通过 Packagist 来安装 Boris。当然你也可以直接克隆它的 git 仓库：<br/><br/>git clone git://github.com/d11wtq/boris.git<br/>cd boris<br/>./bin/boris<br/>Boris以MIT许可证发布。更多信息请访问Boris在GitHub上的项目主页。<br/><br/>[root@localhost local]# git clone git://github.com/d11wtq/boris.git<br/>Cloning into &#039;boris&#039;...<br/>remote: Counting objects: 1061, done.<br/>remote: Total 1061 (delta 0), reused 0 (delta 0), pack-reused 1061<br/>Receiving objects: 100% (1061/1061), 204.32 KiB &#124; 62 KiB/s, done.<br/>Resolving deltas: 100% (506/506), done.<br/><br/><br/>[root@localhost local]# cd boris<br/>[root@localhost boris]# ./bin/boris<br/><br/>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] php -a 交互式 0 === false???,PHP 的 Interactive shell 模式，Centos安装git并装Boris不用重新编译PHP实现类python命令行交互。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>