Some Useful PHP Functions

Jan 20, 2014, by admin

Hi all now we are going to see some useful php functions which will help you more the functions are of given below

Highlight_string

The highlight_string() function can be very helpful while displaying PHP code on a website. The function returns a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax highlighter for PHP. There are two parameters in function, first parameter will be string that can be highlighted and second parameter will be set to TRUE to make this function return the highlighted code.

<?php
highlight_string(' <?php phpinfo(); ?>');
?>

Show_source

The show_source() function is also very handy which works similar to highlight_file (). The function displays a file with the PHP syntax highlighted. The syntax is highlighted by using HTML tags. This function returns TRUE on success, or FALSE on failure.

?php
show_source("php_script.php");
?>

php_strip_whitespace

As explained earlier, this is similar to show_source() function. This function also returns the source code of the specific file by removing PHP comments and whitespace

<?php
echo php_strip_whitespace("php_script.php");
?>

highlight_file

This is a very PHP function which return specific PHP file with the PHP syntax highlighted.

<?php
highlight_file("php_script.php");
?>

 ignore_user_abort

This function can be used to client abot script. The client aborts will cause the script to stop running.

<?php
ignore_user_abort();
?>