As all of you know that PHP has a large set of functions for the programmers. The list is so huge that we keep on learning each one of them day by day. There are some cases you would like to know them beforehand to use them in your app. These are those functions which may be famous for some, but largely people are ignorant about their existance. Here goes the list.
- highlight_string: When you want to give away some PHP code as example and want it syntax highlighted, what would be your next step? Get some highlighting plugin? Use this function, pass the string and the highlighted string is printed as the output. If you don’t want to print it, instead want to store in some variable, pass the second variable as true. Details
- htmlspecialchars: If you have a HTML code to show as an example and want to print it out on the page, simply echoing wont suffice, since the tags would be rendered by the browser as HTML tags. This function converts < to < and > to > and other such special chars into their respective representation. Details
- chr: It is used to convert a number to its ASCII character. The paramter of the function is the integer and output is the character from the ASCII table. Details
- ord: This is just the reverse of chr. It takes a single character as input and returns back the ASCII value of the character. It’s a reverse mapping of chr. Details
- xdiff_file_diff : Taking file differences is one of the oldest thing which existed on a computer. The *nix diffutils is a great source of diff for system admins. Let’s make it available on PHP too. this function takes 3 compulsory arguments – first is the old file, second is the new file and the third being the difference file where the diff is stored. You can use the xdiff_file_patch to patch the files. Details