Chinaunix

标题: 如何将PHP 中的参数传给 BASH SHELL [打印本页]

作者: f980215    时间: 2006-01-04 17:32
标题: 如何将PHP 中的参数传给 BASH SHELL
在其他语言编写的Shell脚本中包含PHP编写的Shell脚本:

#!/bin/bash
echo This is the Bash section of the code.

/usr/local/bin/php -q << EOF
<?php
\$myVar = 'PHP';
print("This is the \$myVar section of the code\n");
?>
EOF

问: 如何将PHP 中的参数$myVar 传给 BASH SHELL

TKS
作者: 寂寞烈火    时间: 2006-01-04 17:54
把php段写成函数
例如:

  1. ...
  2. Php ()
  3. {
  4. #Here,write ur php code
  5. }
  6. var=$(Php)
  7. ...
复制代码

BTW:为测试
作者: f980215    时间: 2006-01-04 20:17
不明白,可给个简单的例子吗

TKS
作者: 寂寞烈火    时间: 2006-01-04 23:49
原帖由 f980215 于 2006-1-4 20:17 发表
不明白,可给个简单的例子吗

TKS

我给你的例子还不够简单?
作者: biaog    时间: 2006-01-05 11:11
在shell中加入php,楼主想达到什么效果阿 ?




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2