I want PHP scripts to run both on command line and website (I use Apache and Nginx) so I put #!/usr/bin/php in the first line of my scripts but that appears on the website...
Choose words carefully Show-offs continue to seek attention until they get it, so ignoring their behaviour is unlikely to make it stop. Praise them, but choose your words carefully. 'Saying, “You're so good at this” reinforces the idea that they're special and stand out,' says psychologist Jean Twenge.
Insecurity. It's the most common reason behind showiness. A person shows off only when they need to. Only when they think that others don't consider them important will they try to prove that they're important.
The content which you show off is of great importance. Everything cannot be of great importance in ones life until it is very expensive, everyone will agree with this point. Show off is something that you wish to show everyone about the matter or object or anything that makes you feel unique.
I solved the problem using output buffering. My script now looks like this:
#!/usr/bin/php
<?php
@ob_end_clean();
...
Note: There is no ?>
at the end of the file. This is actually a good practice when writing PHP scripts. This prevents any garbage text to be accidentally printed.
Note: The PHP documentation for ob_end_clean()
says that:
The output buffer must be started by ob_start() with PHP_OUTPUT_HANDLER_CLEANABLE and PHP_OUTPUT_HANDLER_REMOVABLE flags. Otherwise ob_end_clean() will not work.
It seems that this is done automatically when PHP runs from command line.
There is no need to have #!/usr/bin/php
in your code, just run CLI script using php
, for example php /path/to/file.php
or /usr/bin/php /path/to/file.php
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With