Pure PHP - PHP https://www.pure-php.de/taxonomy/term/6/0 en Lightweight, but Powerful PHP5 XML-RPC Server https://www.pure-php.de/node/31 <p>I have written a XML-Server in PHP5.<br /> It is very easy to use. Just include the file and run the server.<br /> It has some restrictions, it accepts only functions and static methods. you don't have to to change your code if your methods return a php type. (string, array, integer)<br /> Example<br /> <div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br />$ws&nbsp;</span><span style="color: #006600">=&nbsp;new&nbsp;</span><span style="color: #0000CC">XML_RPC_Server</span><span style="color: #006600">();<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">registerFunction</span><span style="color: #006600">(</span><span style="color: #CC0000">'getTime'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">registerMethod</span><span style="color: #006600">(</span><span style="color: #CC0000">'Product::getPrice'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">registerMethod</span><span style="color: #006600">(</span><span style="color: #CC0000">'Product::getDetail'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">registerMethod</span><span style="color: #006600">(</span><span style="color: #CC0000">'Product::getBinaryPicture'</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">$ws</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">run</span><span style="color: #006600">();<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div><br /> Example Source,<br /> http://www.pure-php.com/php/service.source.php<br /> The Server<br /> http://www.pure-php.com/php/xmlrpc.php.txt</p> <p><a href="https://www.pure-php.de/node/31">read more</a></p> https://www.pure-php.de/node/31#comment PHP Thu, 09 Mar 2006 22:59:47 +0100 pure-php 31 at https://www.pure-php.de Security matters, specially for PHP-Magazine, some source code publicly accessible! https://www.pure-php.de/node/24 <p><strong><br /> PHP-Magazine has fixed this secutrity leak, it is not possible to read any source code. This posting ist not up to date anymore </strong> </p> <p>------------------------------------------------------<br /> It is not an April joke! I read frequently PHP-Magazine (http://php-mag.net http://php-mag.de), Yesterday I discovered some interesting things, because I was able, to read some source code and they are still publicly available. I don’t want to write, how I could read the source code, because there are always some people out side, who want play with it. Very important, they have <strong>register_globals on</strong>. I hope, they fix it as soon as possible.</p> <p><a href="https://www.pure-php.de/node/24">read more</a></p> https://www.pure-php.de/node/24#comment PHP Fri, 01 Apr 2005 09:59:12 +0200 pure-php 24 at https://www.pure-php.de include_once / require_once Wrapper Class optimized https://www.pure-php.de/node/22 <p>When I posted my Idea of building a wrapper class for include_once and require_once, I didn't think, that the many php developer would like it. But I was wrong, fortunately.</p> <p>Thanks to <a href="https://www.pure-php.de/node/19#comment-8">Mathias Taylor</a> for benchmarking. Special thanks goes to <a href="https://www.pure-php.de/node/19#comment-15">Cristian Strian</a> for his suggestion to optimize the class, and make it faster. That is the optimized wrapper class. </p> <p><strong>Usage:</strong><br /> <div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br /></span><span style="color: #006600">require(</span><span style="color: #CC0000">"includeWrapper.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"test.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"test.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"test.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">print_r</span><span style="color: #006600">(</span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">getPaths</span><span style="color: #006600">());<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div></p> <p><strong>Output:</strong><br /> Array<br /> (<br /> [test.php] =&gt; 1<br /> )</p> <p>The class itself.</p> <p><div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br /></span><span style="color: #006600">class&nbsp;</span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;</span><span style="color: #0000CC">$paths&nbsp;</span><span style="color: #006600">=&nbsp;array();<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!isset(</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">])){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">]&nbsp;=&nbsp;</span><span style="color: #0000CC">true</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000CC">requireOnce</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!isset(</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">])){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">]&nbsp;=&nbsp;</span><span style="color: #0000CC">true</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF9900">//&nbsp;just&nbsp;for&nbsp;testing<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #006600">public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000CC">getPaths</span><span style="color: #006600">(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div></p> https://www.pure-php.de/node/22#comment PHP Fri, 25 Mar 2005 23:38:00 +0100 pure-php 22 at https://www.pure-php.de Fatal Error is the Fatal Error of PHP - How to avoid it https://www.pure-php.de/node/21 <p>One of the disadvantages of PHP, and one of the things I don't like about the php, is the fatal error, because there isn't any way to avoid it. Well PHP is actually thought to be used in web environment, therefor it is not so important, if your script causes a fatal error, then only the execution of the script for a single request would be terminated.</p> <p>In PHP command line apps, it is really fatal, if your app causes a fatal error, because you have to restart your app. Well you can avoid this, if you write your app very carefully. You should always use <strong>if(function_exists("a_func")) and if(method_exists("a_method"))</strong>. Now you can be pretty sure, that the script won't cause any fatal error.<br /> If you dynamically load third party modules in your app, you have a real problem, because the included module could cause a fatal error, your app would be terminated. There is on way to avoid it. Use <strong>call_user_func</strong>. You can replace in third party modules every function call and method call with call_user_func. For example.<br /> <div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br /></span><span style="color: #006600">function&nbsp;</span><span style="color: #0000CC">add</span><span style="color: #006600">(</span><span style="color: #0000CC">$a</span><span style="color: #006600">,</span><span style="color: #0000CC">$b</span><span style="color: #006600">){<br />&nbsp;echo&nbsp;</span><span style="color: #0000CC">$a</span><span style="color: #006600">+</span><span style="color: #0000CC">$b</span><span style="color: #006600">;<br />}<br /></span><span style="color: #FF9900">//&nbsp;call&nbsp;the&nbsp;function&nbsp;with&nbsp;a&nbsp;small&nbsp;mistake<br /></span><span style="color: #0000CC">ad</span><span style="color: #006600">(</span><span style="color: #0000CC">2</span><span style="color: #006600">,</span><span style="color: #0000CC">3</span><span style="color: #006600">);&nbsp;</span><span style="color: #FF9900">//&nbsp;causes&nbsp;a&nbsp;fatal&nbsp;error<br />//replace&nbsp;it&nbsp;with<br /></span><span style="color: #0000CC">call_user_func</span><span style="color: #006600">(</span><span style="color: #CC0000">"ad"</span><span style="color: #006600">,</span><span style="color: #0000CC">2</span><span style="color: #006600">,</span><span style="color: #0000CC">3</span><span style="color: #006600">);&nbsp;</span><span style="color: #FF9900">//&nbsp;causes&nbsp;a&nbsp;warning<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div></p> https://www.pure-php.de/node/21#comment PHP Wed, 23 Mar 2005 14:42:00 +0100 pure-php 21 at https://www.pure-php.de PHP Command Line - Avoid several Instances of your App. https://www.pure-php.de/node/20 <p>Since PHP 4, you can also write command line apps in php. If you have a critical app, and you want to avoid several, or mor than one instance of your app, to run, you can use the following class. It works only on unix and linux operating sytems.</p> <p>Usage:<br /> <div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br />inlude</span><span style="color: #006600">(</span><span style="color: #CC0000">"ProcessHandler.class.php"</span><span style="color: #006600">);<br />if(</span><span style="color: #0000CC">ProcessHandler</span><span style="color: #006600">::</span><span style="color: #0000CC">isActive</span><span style="color: #006600">()){<br />&nbsp;&nbsp;&nbsp;die(</span><span style="color: #CC0000">"Already&nbsp;running!\n"</span><span style="color: #006600">);<br />}else{<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">ProcessHandler</span><span style="color: #006600">::</span><span style="color: #0000CC">activate</span><span style="color: #006600">();<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF9900">//run&nbsp;my&nbsp;app<br /></span><span style="color: #006600">}<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div></p> <p><a href="https://www.pure-php.de/node/20">read more</a></p> https://www.pure-php.de/node/20#comment PHP Tue, 22 Mar 2005 00:39:01 +0100 pure-php 20 at https://www.pure-php.de include_once Wrapper Class https://www.pure-php.de/node/19 <p>There hase been some discussion in the recend days about the performance of include_once. Inlude_once is really slower than include. For the inclusion of the classes you can use<br /> class_exists('PEAR') or require_once 'PEAR.php' (<a href="http://www.akbkhome.com/blog.php/View/76/require_once%2C+one+optimization+too+many%3F.html">www.akbkhome.com/blog...</a>); </p> <p>You can also use this wrapper class for include_once and require_once, it is faster.</p> <p><div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br /></span><span style="color: #006600">class&nbsp;</span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">{<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;static&nbsp;</span><span style="color: #0000CC">$paths&nbsp;</span><span style="color: #006600">=&nbsp;array();<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: #0000CC">in_array</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">,</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;include(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[]&nbsp;=&nbsp;</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;static&nbsp;function&nbsp;</span><span style="color: #0000CC">requireOnce</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(!</span><span style="color: #0000CC">in_array</span><span style="color: #006600">(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">,</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require(</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">self</span><span style="color: #006600">::</span><span style="color: #0000CC">$paths</span><span style="color: #006600">[]&nbsp;=&nbsp;</span><span style="color: #0000CC">$path_file</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"Class1.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">requireOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"Class1.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">includeWrapper</span><span style="color: #006600">::</span><span style="color: #0000CC">includeOnce</span><span style="color: #006600">(</span><span style="color: #CC0000">"Class2.class.php"</span><span style="color: #006600">);<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div></p> https://www.pure-php.de/node/19#comment PHP Fri, 18 Mar 2005 00:17:28 +0100 pure-php 19 at https://www.pure-php.de PHP Command Line rocks https://www.pure-php.de/node/16 <p>Recently I wrote a PHP Command line app, I was amazed, how easy it was, to write command line app in PHP, and it really rocks.</p> <p>Here is very simple Command Line handler class, it may be usefull for your apps.<br /> <div class="codeblock"><code><span style="color: #000000"> <span style="color: #0000CC">&lt;?php<br /></span><span style="color: #006600">class&nbsp;</span><span style="color: #0000CC">CliHandler</span><span style="color: #006600">{<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000CC">$in</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000CC">$out</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000CC">$handler</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000CC">CliHandler</span><span style="color: #006600">(</span><span style="color: #0000CC">$handler</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">in&nbsp;</span><span style="color: #006600">=&nbsp;</span><span style="color: #0000CC">fopen</span><span style="color: #006600">(</span><span style="color: #CC0000">"php://stdin"</span><span style="color: #006600">,</span><span style="color: #CC0000">"r"</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">out&nbsp;</span><span style="color: #006600">=&nbsp;</span><span style="color: #0000CC">fopen</span><span style="color: #006600">(</span><span style="color: #CC0000">"php://stdout"</span><span style="color: #006600">,&nbsp;</span><span style="color: #CC0000">"w"</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000CC">is_object</span><span style="color: #006600">(</span><span style="color: #0000CC">$handler</span><span style="color: #006600">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">handler&nbsp;</span><span style="color: #006600">=&nbsp;</span><span style="color: #0000CC">$handler</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000CC">run</span><span style="color: #006600">(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$str&nbsp;</span><span style="color: #006600">=&nbsp;</span><span style="color: #CC0000">"Try&nbsp;these&nbsp;commands:\n"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #006600">.</span><span style="color: #0000CC">implode</span><span style="color: #006600">(</span><span style="color: #CC0000">"\n"</span><span style="color: #006600">,</span><span style="color: #0000CC">get_class_methods</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">handler</span><span style="color: #006600">));<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">out</span><span style="color: #006600">(</span><span style="color: #0000CC">$str</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(</span><span style="color: #0000CC">$line&nbsp;</span><span style="color: #006600">=&nbsp;</span><span style="color: #0000CC">rtrim</span><span style="color: #006600">(</span><span style="color: #0000CC">fgets</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">in</span><span style="color: #006600">,&nbsp;</span><span style="color: #0000CC">1024</span><span style="color: #006600">))){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000CC">method_exists</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">handler</span><span style="color: #006600">,</span><span style="color: #0000CC">$line</span><span style="color: #006600">)){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$out&nbsp;</span><span style="color: #006600">=&nbsp;</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">handler</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">$line</span><span style="color: #006600">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000CC">$out</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">out</span><span style="color: #006600">(</span><span style="color: #0000CC">$out</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000CC">out</span><span style="color: #006600">(</span><span style="color: #0000CC">$str</span><span style="color: #006600">){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000CC">fwrite</span><span style="color: #006600">(</span><span style="color: #0000CC">$this</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">out</span><span style="color: #006600">,</span><span style="color: #0000CC">$str</span><span style="color: #006600">.</span><span style="color: #CC0000">"\n"</span><span style="color: #006600">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br />class&nbsp;</span><span style="color: #0000CC">AnyClass</span><span style="color: #006600">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000CC">start</span><span style="color: #006600">(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #CC0000">"started"</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000CC">stop</span><span style="color: #006600">(){<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #CC0000">"stoppded"</span><span style="color: #006600">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000CC">$cli&nbsp;</span><span style="color: #006600">=&nbsp;new&nbsp;</span><span style="color: #0000CC">CliHandler</span><span style="color: #006600">(new&nbsp;</span><span style="color: #0000CC">AnyClass</span><span style="color: #006600">());<br /></span><span style="color: #0000CC">$cli</span><span style="color: #006600">-&gt;</span><span style="color: #0000CC">run</span><span style="color: #006600">();<br /></span><span style="color: #0000CC">?&gt;</span> </span> </code></div></p> <p>CliHandler accepts any class als argument.<br /> Try this.</p> <p>/usr/local/php/PHP5 CliHandler.class.php<br /> output: Try these command:<br /> start<br /> stop<br /> enter "start"<br /> output: started</p> https://www.pure-php.de/node/16#comment PHP Sun, 13 Mar 2005 16:19:29 +0100 pure-php 16 at https://www.pure-php.de PHP must free itself from Apache Server https://www.pure-php.de/node/10 <p>There has been a lot of Discussions about Enterprise PHP, specially after the release of PHP 5. PHP has a much better Object Model now, butt PHP is still NOT enterprise ready.</p> <p>The first step toward enterprise is PHP's emancipation from Apache Web server. Since 4.1.0 Version, PHP supports sockets. Therefore PHP itself can serve HTTP Requests. Although PHP sockets are experimental, but it really rocks. I have written a simple IRC Sever in PHP using PHP sockets and it is up since about 70 days.</p> <p><a href="https://www.pure-php.de/node/10">read more</a></p> https://www.pure-php.de/node/10#comment PHP Wed, 02 Mar 2005 21:24:07 +0100 pure-php 10 at https://www.pure-php.de Pure-PHP goes online https://www.pure-php.de/node/8 <p>Pure-PHP goes online</p> https://www.pure-php.de/node/8#comment PHP Wed, 02 Mar 2005 20:30:46 +0100 pure-php 8 at https://www.pure-php.de
Datenschutz | Impressum