Asked by duncanb7
at 2024-03-20 02:33:48
Point:500 Replies:8 POST_ID:828898USER_ID:11059
Topic:
PHP Scripting Language;Apache Web Server;Linux
I don't know why when I pass variable into php script on command line
that doesn't work, for example, the following test.php code. Nothing
is echo out.
php test.php 1 2 3 5
#!/usr/bin/php
<?php
echo $argv[1]."";
echo $argv[2]."';
var_dump($argc);
?>
I am using php version as follows
PHP 5.3.21 (cli) (built: Feb 4 2013 12:36:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies
I also try php -f test.php 1 2 3 4 but it also fail.
Do I need to add some option or setting in php.ini before doing passing variable
on command line into php script ? Or is it related to the type of console shell I am
using ? I am using BASH linux shell on apache linux server and I am through my home computer putty software connecting to remoter server.
Please advise
Duncan
that doesn't work, for example, the following test.php code. Nothing
is echo out.
php test.php 1 2 3 5
#!/usr/bin/php
<?php
echo $argv[1]."";
echo $argv[2]."';
var_dump($argc);
?>
I am using php version as follows
PHP 5.3.21 (cli) (built: Feb 4 2013 12:36:43)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd., and
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies
I also try php -f test.php 1 2 3 4 but it also fail.
Do I need to add some option or setting in php.ini before doing passing variable
on command line into php script ? Or is it related to the type of console shell I am
using ? I am using BASH linux shell on apache linux server and I am through my home computer putty software connecting to remoter server.
Please advise
Duncan