PHP头条
热点:

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


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

PHP code

 '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 

[User:root Time:07:23:12 Path:/home/liangdong/php]$ cat b.php 
 '1',
                    'b' => '2',
                          'c' => 'public',
                            'd' => '',
                                  'e' => '',
                );
?>

------解决方案--------------------
shell不熟,估计你的需求我以后会用的,就研究了一个,

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}

------解决方案--------------------
跨语言的数据交换,需采用双方都能识别的数据结构,
否则就毫无意义

如果你示例 php 代码是被 zend 预编译过的,或是被威盾扰码过的(你不能说他就不是php文件了吧)
那你在 shell 中再如何分离出数据?

www.phpzy.comtrue/phprm/52174.htmlTechArticle【貌似有挑战性】shell怎么获取php中return的值 【貌似有挑战性】shell如何获取php中return的值 如题 php这个文件就是返回一个数组 PHP code '1', 'b' => '2', 'c' => 'public', 'd' => '', 'e' => '',);?> 在s...

相关文章

PHP之友评论

今天推荐