让php.exe也能传递参数
来源:互联网 发布:网络教师兼职平台 编辑:程序博客网 时间:2024/05/01 18:39
在项目中使用到windows的定时任务来执行php,但是发现配合ci,却找不到方法来传递uri参数,手动$_SERVER["REQUEST_URI"]可以浏览器中正常运行.但是放到cmd下面的php.exe来运行时,却发现参数在另一个数组中.简单的方法就是改uri的获取方式了.加上cmd的情况下的提取
-------------
在命令行中调用
>php.exe cmd.php
-------
cmd.php
虽然设置了
$_SERVER["REQUEST_URI"] = 'home/email/queue/' .$maxLetters. '/' .$sleep;
但是在cmd php.exe中调试打印出$_SERVER,竟然无此参数,参数自动跑到argc的数组下面去.
没办法只能改core中的代码了.
--------
<?php
$maxLetters = 10;//运行一次发送件数
$sleep = 20; //如果相同dns暂停秒后再发送,可以设置0,然后启用smtp中的间隔时间
$_SERVER["REQUEST_URI"] = 'home/email/queue/' .$maxLetters. '/' .$sleep;
phpinfo();
include('index.php');
----------
修改core/uri.php中的
增加
empty($uri) && isset($_SERVER["argc"]) && (!empty($_SERVER["argc"]['REQUEST_URI'])) && ($uri = $_SERVER["argc"]['REQUEST_URI']);//qidizi增加,让cmd php.exe也支持此参数
/**
* Get the URI String
*
* @access private
* @return string
*/
function _fetch_uri_string()
{
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
{
// Is the request coming from the command line?
if (defined('STDIN'))
{
$this->_set_uri_string($this->_parse_cli_args());
return;
}
// Let's try the REQUEST_URI first, this will work in most situations
if ($uri = $this->_detect_uri())
{
$this->_set_uri_string($uri);
return;
}
// Is there a PATH_INFO variable?
// Note: some servers seem to have trouble with getenv() so we'll test it two ways
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
if (trim($path, '/') != '' && $path != "/".SELF)
{
$this->_set_uri_string($path);
return;
}
// No PATH_INFO?... What about QUERY_STRING?
$path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
if (trim($path, '/') != '')
{
$this->_set_uri_string($path);
return;
}
// As a last ditch effort lets try using the $_GET array
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
{
$this->_set_uri_string(key($_GET));
return;
}
// We've exhausted all our options...
$this->uri_string = '';
return;
}
$uri = strtoupper($this->config->item('uri_protocol'));
if ($uri == 'REQUEST_URI')
{
$uri = $this->_detect_uri();
empty($uri) && isset($_SERVER["argc"]) && (!empty($_SERVER["argc"]['REQUEST_URI'])) && ($uri = $_SERVER["argc"]['REQUEST_URI']);//qidizi增加,让cmd php.exe也支持此参数
$this->_set_uri_string($uri);
return;
}
elseif ($uri == 'CLI')
{
$this->_set_uri_string($this->_parse_cli_args());
return;
}
$path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
$this->_set_uri_string($path);
}
- 让php.exe也能传递参数
- exe传递参数
- php能把函数名作为参数传递吗?
- 让DataList也能分页
- 让文本文件也能下载!
- php打开本地exe程序,js打开本地exe应用程序,并传递相关参数
- VB EXE程序传递参数
- 传递命令行参数调用exe
- C# 调用exe 传递参数
- MFC 启动exe 参数传递
- 让你的PHP也能执行JS并获得JS函数的返回值
- [转]让DataList也能分页
- 让Windows XP也能自动登录
- 让表格也能overflow:hidden?
- 让web程序也能自动安装
- 让web程序也能自动安装
- 让控制台程序也能拥有进度条
- 让笔记本也能但WIFI
- 求助关于位图的读写,不解的地方
- dom麻烦的写法 --> 原来已经有写好的库
- Dialog和add(Field)
- 使用kxml2-min-2.3.0.jar时的错误解决方法:Missing stack map in: <init> at label: 79
- URI,URL,URN区别
- 让php.exe也能传递参数
- 12个高矮不同的人,排成两排,每排必须是从矮到高排列,而且第二排比对应的第一排的人 高,问排列方式有多少种?
- 修改CI的form验证错误输出格式,配合jq的form 验证格式
- ci添加任意图片验证码方式
- ci的form验证自定函数回调方式
- firefox的标签打开contenteditable属性时能够跨区删除
- 多用户共享表时,删除数据库记录时最容易忽略的安全逻辑条件
- linux 目录作用说明
- 卸载Microsoft .NET Framework方法