Maison >développement back-end >tutoriel php > 【貌似有挑战性】shell怎么获取php中return的值
【貌似有挑战性】shell如何获取php中return的值
如题 php这个文件就是返回一个数组
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --> <?php return array ( 'a' => '1', 'b' => '2', 'c' => 'public', 'd' => '', 'e' => '', ); ?>
[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>
#!/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>