php Bin2PHP

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Bin2PHP相关的知识,希望对你有一定的参考价值。

<span style="color: #000000; font-weight: bold;">function</span> bin2php<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$input_file</span>, <span style="color: #0000ff;">$output_file</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
    <span style="color: #0000ff;">$i</span> = <a href="http://www.php.net/file_get_contents"><span style="color: #000066;">file_get_contents</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$input_file</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #0000ff;">$b</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$x</span> = <span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$y</span> = <span style="color: #cc66cc;">0</span>;
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$c</span>=<span style="color: #cc66cc;">0</span>; <span style="color: #0000ff;">$c</span> &lt; <a href="http://www.php.net/strlen"><span style="color: #000066;">strlen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #0000ff;">$c</span>++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
        <span style="color: #0000ff;">$no</span> = <a href="http://www.php.net/bin2hex"><span style="color: #000066;">bin2hex</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$c</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$x</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/isset"><span style="color: #000066;">isset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$x</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> ? <span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$x</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\\</span>x'</span>.<span style="color: #0000ff;">$no</span> : <span style="color: #ff0000;">'<span style="color: #000099; font-weight: bold;">\\</span>x'</span>.<span style="color: #0000ff;">$no</span>;
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$y</span> &gt;= <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> 
            <span style="color: #0000ff;">$x</span>++; <span style="color: #0000ff;">$y</span> = <span style="color: #cc66cc;">0</span>;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #0000ff;">$y</span>++;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">$output</span> = <span style="color: #ff0000;">&quot;&lt;&quot;</span>.<span style="color: #ff0000;">&quot;?php<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
    <span style="color: #0000ff;">$output</span> .= <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\$</span>f=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>;
    <span style="color: #0000ff;">$output</span> .= <a href="http://www.php.net/implode"><span style="color: #000066;">implode</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\$</span>f.=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span>, <span style="color: #0000ff;">$b</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #0000ff;">$output</span> .= <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>;<span style="color: #000099; font-weight: bold;">\n</span>print <span style="color: #000099; font-weight: bold;">\$</span>f;&quot;</span>;
    <span style="color: #0000ff;">$output</span> .= <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>?&gt;&quot;</span>;
&nbsp;
    <span style="color: #0000ff;">$fp</span> = <a href="http://www.php.net/fopen"><span style="color: #000066;">fopen</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$output_file</span>, <span style="color: #ff0000;">'w+'</span><span style="color: #66cc66;">&#41;</span>;
    <a href="http://www.php.net/fwrite"><span style="color: #000066;">fwrite</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span>, <span style="color: #0000ff;">$output</span><span style="color: #66cc66;">&#41;</span>;
    <a href="http://www.php.net/fclose"><span style="color: #000066;">fclose</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$fp</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>

以上是关于php Bin2PHP的主要内容,如果未能解决你的问题,请参考以下文章

php [guzzle php] guzzle php #php

php send.php php邮件模板#php

IntelliJ IDEA 11编辑php是,支持php文件名为.php5和.php4,如何设置能让其也支持.php呢?

如何从php5升级到php7

请问php中如何调用php文件中的内容?

php [php:PHPMailer示例] php库“PHPMailer”示例。 #PHP