Operating System - OpenVMS
Showing results for 
Search instead for 
Did you mean: 

Paramater passing - PHP

Go to solution
Paul Beaudoin
Regular Advisor

Paramater passing - PHP


Further to my last thread in which I got PHP to work at DCL level, I now need to know how to pass paramaters to a PHP script called from DCL. I assume this can be done but can't find any references either on the web or in the manual.

Thanks for any hints


PS. for anyone interested, I am experimenting with the FPDF package to create PDFs from text files. With some interesting anomolies, it seems to work well and I can recommend it (so far!)

Wim Van den Wyngaert
Honored Contributor

Re: Paramater passing - PHP

Somewhere on this forum I posted txt2pdf that I corrected to show larger files too (e.g. 300 char/line listings we like to show on the screen).

I also saw a2html that converts normal listings with cobol style tables to html with tables (that you can move to XL with the right mouse button).


Robert Atkinson
Respected Contributor

Re: Paramater passing - PHP

Paul, this is documented at http://uk2.php.net/manual/en/features.commandline.php (including some useful examples) :-

"Like every shell application, the PHP binary accepts a number of arguments but your PHP script can also receive arguments. The number of arguments which can be passed to your script is not limited by PHP (the shell has a certain size limit in the number of characters which can be passed; usually you won't hit this limit). The arguments passed to your script are available in the global array $argv. The zero index always contains the script name (which is - in case the PHP code is coming from either standard input or from the command line switch -r). The second registered global variable is $argc which contains the number of elements in the $argv array (not the number of arguments passed to the script)."


Paul Beaudoin
Regular Advisor

Re: Paramater passing - PHP


Ummm... wow... that (at first attempt!) seems to do the trick. 20 out of 10!

Thanks muchly

(Though for general interest I'd still like to know how to pass the params so I don't have to ask again in another contect)

Best regards

Paul Beaudoin
Regular Advisor

Re: Paramater passing - PHP

I'm sorry - I missed your message earlier- it is entirely correct as I since discovered. Using this call:
php test_param.php P1=1 P2=2 P3=3

Where the file is:


Content-type: text/html
X-Powered-By: PHP/4.3.2

[0] => test_param.php
[1] => p1=1
[2] => p2=2
[3] => p3=3

As you can see, arg 0 is the script name followed by args 1-n in the array. I bet if I echoed $argc it would have given the correct result.
Many thanks

Paul Beaudoin
Regular Advisor

Re: Paramater passing - PHP

Thanks to all for the replies - original problem solved and a possibly better solution found! Doesn't get better than that.