Dev Corner

Software Developer’s Notepad

Archive for the ‘PHP’ Category

Problem: You have a string encoded in UTF-8 and you need to convert it to two byte UTF encoded string. For example, you might want to display convert the string to CP1251 (Windows-1251) encoding using standard encoding tables. Read the rest of this entry »

PHP implements a bin2hex function that converts given binary string to hexadecimal string. Sometimes you need to solve the reverse task. You are given hexadecimal string and you need a PHP function that converts it to a binary string. Read the rest of this entry »

Input stream are useful as they encapsulate concrete implementation of a data source. You can change the data source without changing the application code. For example, you application reads data from a file. One day your boss decides that you need to retrieve information from a server located 1000 miles away. You just implement another class that implements the same input stream interface. The new class retrieves data from network instead of a local file. Read the rest of this entry »

Check if variable is a number in PHP

Posted by bateto under PHP

It is useful to know the type of the variables, with which you are operating. But in PHP there are not declarations, in which we point out what the type of the variable to be. Read the rest of this entry »