Created
February 8, 2012 02:07
-
-
Save gautamk/1764392 to your computer and use it in GitHub Desktop.
Testing single line php code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# What if you wanted to test a single line of code in php ? | |
# Simple | |
echo "<?php phpinfo();" | /path/to/php | |
# Since I am using XAMPP | |
# The following works | |
echo "<?php phpinfo();" | /opt/lampp/bin/php | |
# If you need sudo permissions | |
echo "<?php phpinfo();" | sudo /opt/lampp/bin/php | |
# Replace phpinfo(); with any statement that needs to be executed | |
# The above examples will work for any Unix Based Operating Systems (Linux & Mac) | |
# Sorry windows users I think it will work but I am not sure (Read http://commandwindows.com/command1.htm) | |
# Sorry I forgot about Interactive mode which you can use for the same purpose | |
# http://www.php.net/manual/en/features.commandline.options.php | |
# http://www.php.net/manual/en/features.commandline.interactive.php | |
/path/to/php -a | |
# Remember Interactive mode does not work with XAMPP | |
# But my method does !! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment