【貌似有挑战性】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>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号