douju7765 2015-10-05 18:57
浏览 34

排除Codeigniter CLI故障

I have been using the CLI interface to send out cron jobs from my codeigniter page. It worked fine until I updated Wordpress yesterday. I do not know how this effected Codeigniter but that is when the trouble started. I also installed cURL at about the same time. I am not sure if that could have made a difference.

SYMPTOMS: None of my codeigniter CLI scripts work. I have two scripts that send out email reminders, and another that synchronizes my database and none function.

ERRORS: I had some errors come up when I tried to run my scripts such as:

Use of undefined constant __DIR__ - assumed '__DIR__'

This was never a problem before. But for now I change that to

dirname(__FILE__) 

and that seemed to help. At least that error stopped.

Next another error notice appeared regarding code in my scripts that I was not getting before: "Can't use method return value in write context in . . ."

This error was in reference to this line of code:

if (!empty($this->get_available_hours($date, $provider_id))) {

I modified this to

$availabehours=$this->get_available_hours($date, $provider_id);
if (!empty($availabehours)) {

And the error stopped. But the script usually sends out email regarding availability and no email is sent.

Now I have no errors. I run the scripts and I get no results. If I purposefully mess with the code and do things wrong, I get the appropriate error messages. So, at some level it is reading the file.

I tried just running a simple "hello world file" as discribed here https://ellislab.com/codeigniter/user-guide/general/cli.html And nothing was returned.

I tried a simple email script that would send out an email without accessing my database and it did not send anything to me.

It appeares to me like something has caused my code to be interpreted in an older version of php. So I looked at the version currently running: When logged into the terminal in PuTTY I get: PHP 5.2.17 (cli) (built: Feb 23 2012 10:42:34) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies Out of date ...

But when I look in the terminal within WinSCP I get: PHP 5.5.28 (cli) (built: Sep 4 2015 12:07:49) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

This looks up to date.

Running this works: php -r 'echo "Hello World! ";'

MY QUESTIONS: 1) What tests can I run to find out what is blocking things with my CLI? Any tips would be appreciated. 2) Why am I seeing two different versions of PHP depending on the terminal I am running and could this be the cause of my problem?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡等级和折扣规则
    • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分