Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
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
Author: duncanb7 replied at 2024-03-20 04:19:16
Thanks for your reply
For my memo only:
1-Temporarily use $_server instead of $argv to solve the issue for continuing project
2- follow up the $argv on command line issue on next new thread later on.
Duncan
For my memo only:
1-Temporarily use $_server instead of $argv to solve the issue for continuing project
2- follow up the $argv on command line issue on next new thread later on.
Duncan
Expert: Guy Hengel [angelIII / a3] replied at 2024-03-20 04:11:17
if the code was in a class module, you would need to declare the variable
global $argv;
first before using it, but other than that, I don't see why it isn't filled.
global $argv;
first before using it, but other than that, I don't see why it isn't filled.
Author: duncanb7 replied at 2024-03-20 04:03:11
it is same and NOT working using php-cli with $argv , and $_server is working
with both
If you have time, I am appreciated you can explain it between $argv and $_server['argv']
Have a nice day
Duncan
with both
If you have time, I am appreciated you can explain it between $argv and $_server['argv']
Have a nice day
Duncan
Expert: Guy Hengel [angelIII / a3] replied at 2024-03-20 04:00:00
would it work if you use
php-cli
instead of
php
php-cli
instead of
php
Author: duncanb7 replied at 2024-03-20 03:27:33
yes, it is array with those variable value including "test.php" ,1,2,3.
Probably I can use $_SERVER instead of $argv for solving the issue
But why the variable is saved at $_SERVER, supposed it is used on Web browser
not on command shell php running ?
Duncan
Probably I can use $_SERVER instead of $argv for solving the issue
But why the variable is saved at $_SERVER, supposed it is used on Web browser
not on command shell php running ?
Duncan
Accepted Solution
Expert: Guy Hengel [angelIII / a3] replied at 2024-03-20 03:23:29
500 points EXCELLENT
does:
$_SERVER[ "argv" ]
contain some data?
$_SERVER[ "argv" ]
contain some data?
Author: duncanb7 replied at 2024-03-20 03:18:50
realpath_cache_ttl 120 120
register_argc_argv On On
register_globals Off Off
register_long_arrays On On
register_argc_argv is ON from phpinfo() in php but still not working
Duncan
register_argc_argv On On
register_globals Off Off
register_long_arrays On On
register_argc_argv is ON from phpinfo() in php but still not working
Duncan
Expert: Guy Hengel [angelIII / a3] replied at 2024-03-20 03:04:13
from the technical refernce:
http://www.php.net/manual/en/reserved.variables.argv.php
Note: This variable is not available when register_argc_argv is disabled.
so, please check you php.ini file:
http://www.php.net/manual/en/ini.core.php#ini.register-argc-argv
http://www.php.net/manual/en/reserved.variables.argv.php
Note: This variable is not available when register_argc_argv is disabled.
so, please check you php.ini file:
http://www.php.net/manual/en/ini.core.php#ini.register-argc-argv