Define a constant in PHP
Answer:
To define a constant in PHP, you can use define()
define ("PI", 3.1415);
echo PI;
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Define a constant in PHP
Answer:
To define a constant in PHP, you can use define()
define ("PI", 3.1415);
echo PI;
How to remove HTML from text using PHP?
Answer:
strip_tags is useful to remove HTML from text .
<?php
$text = '<p>Test paragraph.</p>';
echo strip_tags($text);
Install Xdebug for PHP under Ubuntu
Answer:
Xdebug is a very useful debugging extension for PHP, to install under Ubuntu:
# sudo pecl install xdebug
# echo "extension=xdebug.so" > /etc/php.d/xdebug.ini
Restart Apache and that's all.
How to prevent PHP script from running in Apache
Answer:
If you have a PHP script and want it run under in command line only, not in the web server context, you can use the following method.
<?php
if ( php_sapi_name() != "cli" ) {
print "This script must be run from the command line\n";
exit();
}
How to redirect user to another URL in PHP
Answer:
Assume you have a redirect.php, and want to redirect user to Google, use the following codes:
<?php
header("Location: http://www.google.com");