Skip to content
Advertisement

Undefined variable argc PHP

I’m trying to execute this code:

JavaScript

But I’m getting the following error:

PHP Notice: Undefined variable: argc in /home/me/test.php on line 15

I thought that $argv and $argc were global variables. How can I get rid of this error?

I’m running this from command line.

Advertisement

Answer

Add a

JavaScript

after

JavaScript

Those variables are in global scope, but not in your function’s scope. The global keyword imports them.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement