Home >Backend Development >PHP Tutorial > 【貌似有挑战性】shell怎么获取php中return的值

【貌似有挑战性】shell怎么获取php中return的值

WBOY
WBOYOriginal
2016-06-13 13:27:23933browse

【貌似有挑战性】shell如何获取php中return的值
如题 php这个文件就是返回一个数组 

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php return array (
  'a' => '1',
  'b' => '2',
  'c' => 'public',
  'd' => '',
  'e' => '',
);
?>



在shell如何接收这个数组啊 还是根本没办法

------解决方案--------------------
PHP code
[User:root Time:07:23:08 Path:/home/liangdong/php]$ php a.php 
Array
(
    [a] => 1
    [b] => 2
    [c] => public
    [d] => 
    [e] => 
)
[User:root Time:07:23:10 Path:/home/liangdong/php]$ cat a.php 
<?php $arr = include('b.php');
print_r($arr);
?>
[User:root Time:07:23:12 Path:/home/liangdong/php]$ cat b.php 
<?php return array (
                  'a' => '1',
                    'b' => '2',
                          'c' => 'public',
                            'd' => '',
                                  'e' => '',
                );
?>
<br><font color="#e78608">------解决方案--------------------</font><br>shell不熟,估计你的需求我以后会用的,就研究了一个,<br><br>
PHP code

#!/bin/bash
eval `cat php_data.txt |grep "=>"|tr -d " ,>\'"|xargs -I {} echo {}\;|tr "\n" " "`
echo ${a}
echo ${b}
echo ${c}
echo ${d}
<br><font color="#e78608">------解决方案--------------------</font><br>
跨语言的数据交换,需采用双方都能识别的数据结构,<br>否则就毫无意义<br><br>如果你示例 php 代码是被 zend 预编译过的,或是被威盾扰码过的(你不能说他就不是php文件了吧)<br>那你在 shell 中再如何分离出数据? <div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn