Welcome Guest, Not a member yet? Register   Sign In
Problem run via the command-line [SOLVED]

(This post was last modified: 09-08-2021, 02:54 AM by hieuhiti.)

Hi All,
I create a simple controller for run via the command-line. But When run:
php index.php tools/messages/to

error reporting system

PHP Parse error:  syntax error in /Users/rocker/www/democommand.vn/system/Common.php on line 49

I don't interfere Common.php file. Why error?

Controller I'm refer https://codeigniter.com/user_guide/cli/c...mmand-line

PHP Code:
namespace App\Controllers;


Tools extends Controller
    public function message($to 'World')
        echo "Hello {$to}!" PHP_EOL;

Please helpme.

Please show what code is in line 49

(09-07-2021, 09:08 AM)paulbalandan Wrote: Please show what code is in line 49

PHP Code:
if (! function_exists('app_timezone'))
 * Returns the timezone the application has been set to display
 * dates in. This might be different than the timezone set
 * at the server level, as you often want to stores dates in UTC
 * and convert them on the fly for the user.
 * @return string
function app_timezone(): string
$config config(App::class);


Line 49 is:  function app_timezone(): string

If I delete this function, the same PHP Parse error appear next function has syntax "function {any_name} : string".

I think Terminal don't accept syntax "function {any_name} : string". But This is Ci4 System file, I don't interfere

What PHP version is your terminal using?

Run `php -v`

(This post was last modified: 09-08-2021, 01:54 AM by hieuhiti.)

@paulbalandan, with your suggestion.
After Check Php Version,
I found different between "php -v" and php_info(), I fixed it.
My Problem has been fixed.
Thanks you very much!

For "Problem run via the command-line", We Check Php Version by syntax: "php-v" on terminal. Required php 7.2 or higher

Please edit your post and in the title on top add to the end [SOLVED]

Thank you.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Theme © iAndrew 2016 - Forum software by © MyBB