Syntax highlighting in PHP
Anwser:
PHP has a built-in function that help to to syntax highlight your PHP codes.
E.g.
<?php
$str = <<<EOT
echo "This is a test";
EOT;
highlight_string($str);
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
Syntax highlighting in PHP
Anwser:
PHP has a built-in function that help to to syntax highlight your PHP codes.
E.g.
<?php
$str = <<<EOT
echo "This is a test";
EOT;
highlight_string($str);
Solving the warning message "Xdebug MUST be loaded as a Zend extension"
Answer:
If you have installed the xdebug, and the PHP interpreter show the following warning message every time you execute the php command.
Xdebug MUST be loaded as a Zend extension
It can be solved by adding the following line in your php.ini (Replace the path of you xdebug.so if they are different.)
zend_extension="/usr/local/php/modules/xdebug.so"
And remember to remove any statement like the following which caused the problem..
extension="xdebug.so"
Output the parsable string representation of a variable in PHP
Answer:
var_export allows you to outputs or returns a parsable string representation of a variable.
Example:
<?php
$a = array (
"foo" => 1,
"bar" => 2
);
echo var_export($a);
It gives:
array (
'foo' => 1,
'bar' => 2,
)
So you can use the output to declare the variable again in another PHP file.
Is PHP's function name case-sensitive or case-insensitive?
Answer:
In PHP, the names of user defined classes/functions, as well as those built in language constructs/keywords such as echo, while, etc., are ALL case-insensitive, e.g.
echo "foo";
ECHO "foo";
eCho "foo";
They are all the same.
Replace Unicode character using regex with Perl
Answer:
To use regex to replace Perl's Unicode string, you can try the following.
$text =~ s/[\x{0000}-\x{007F}]+/ /g;
The above code replace all Unicode with codepoint from 0 to 127 by a space.