Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Aug 082010
 

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);
Aug 072010
 

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"

Aug 032010
 

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.