Basics of Command Line PHP

Prince

[ Verified Seller ]
Staff member
Trusted Seller
Joined
11 yrs. 6 mth. 26 days
Messages
5,381
Reaction score
18,380
Age
45
Wallet
11,590$
Hey guys this is a brief tutorial on some of the things you may face in writing command line php scripts. It covers some of the simpler things like obtaining user input as well as basic file processing, we'll finish up by creating a very simple pseudo interactive interpreter in php.

Output:
If you're coming from a background of making web scripts in php you may have the habit of ending lines with <br />, in the CLI this won't work so instead you need to use \n to denote an endline. \r is another useful character which moves the cursor back to the start of the line and overwrites it, this helps in cases where you want to minimize the output of a loop for example. This is pretty simple stuff so I'll just give a few brief examples:

Code:
Please, Log in or Register to view codes content!
 
Top Bottom