PHP

Zyxware default image2
| 7 min read
I was faced with a requirement to convert number to words/string in Indian naming system with lakhs and crores. I had to generate the amount in words for printing it out on a bill. The total amount, provided to the customer, needed to be converted to string. For example, if 1345673 was to be converted to Thirteen lakh Forty Five Thousand Six Hundred and Seventy Three, these functions will have to be followed.
Zyxware default image2
| 4 min read
Comma separated values, commonly referred to as CSV is one of the most popular methods for transferring data between systems. Creating code to export data to CSV is extremely useful in many applications. If you want to know how to create CSV files using PHP then read on.
Zyxware default image4
| 3 min read
cURL is a very powerfull system which allows us to transfer data across a wide variety of protocols. cURL is commonly used to send data across websites which includes API interaction. Using a cURL request, we can do the basic HTTP request, the more complex FTP upload or interaction with an authentication enclosed HTTPS site. In this section we will go through how cURL is intialized, how to send cURL request and close the requests.
Zyxware default image4
| 2 min read
Are you looking for a way manipulate dom elements using javascript based on some values from PHP, then this article is for you. We had recently worked in a Drupal 6 site having the same scenario. Our requirement was to enable some checkboxes using javascript based on the values of some variables available in the backend, This was accomplished using Drupal.settings
Zyxware default image3
| 3 min read
My requirement was to detect the mobile devices from the drupal backend and redirect the user to the assigned URL. For this we needed to identify whether the user was accessing the site from a mobile device. For this we had to check the user agent string and compare that with the most common mobile devices. Then depending upon the condition we redirect the user to the corresponding URL.
Zyxware default image1
| 2 min read
I had a requirement where I had to execute shell command from PHP. The requirement was that I had to find details of a domain using commands like whois and then store this information into files in a folder. The only input parameter for the process was the name of the domain which was passed on from the Drupal site. The PHP function (shell_exec) was designed to do things like this.
Zyxware default image2
| 2 min read
One of the errors we come across in a Drupal 6 installation is "htmlspecialchars() expects parameter 1 to be string, array given in /includes/bootstrap.inc on line 860". This is an issue with the Internationalization and Taxonomy translation modules. This issue can be fixed by adding a line in the bootstrap.inc file. If you want to know how to solve the warning, continue reading.
Zyxware default image3
| 2 min read
The function of the script is to rename a specific-directory present under all sub-directories of a specified parent folder. Consider, you have a particular folder under all sub-directories of a folder and you want to rename all of those occurrences. Doing it manually would take much time. Here is a script to make it easy for you. The script takes the following inputs: 'path' is the absolute path of the parent folder, and 'foldername.txt' is a text file which contains the names of the subdirectories under each of which the specific directory has to be renamed.
Zyxware default image3
| 2 min read
A number of Drupal users have encountered a White screen page accompanied by a "PHP error: Call to a member function value() on a non-object" error message when accessing the Checkout Review page of the Drupal Commerce module. If you are facing the same situation with Drupal Commerce in your Drupal site then read on to find out the solution.
Zyxware default image3
| 2 min read
We have been facing the error message "Fatal error: Class 'PDO' not found in includes/database/database.inc on line 184" in one of our Drupal sites. Googling up the error text had brought out a number of solutions which did not help to resolve the error in our case as there is no single cause of the error. However we managed to solve it using a different method. If you are facing the same scenario in your Drupal site and want to know how to solve fatal error with Class 'PDO' in Drupal sites the continue reading for the solution.
Zyxware default image4
| 2 min read
You might have come across a situation where you need to set the title of the content as the filename for an uploaded image or where you might need to replace the spaces and special characters from the filename of an uploaded file. In such conditions you can use preg_replace. I will show you some example code where the output string will be nice and clean and can be used for setting file names.
Zyxware default image3
| 2 min read
APC or Alternative PHP Cache (APC) is a free and open opcode cache for PHP. APC allows for caching of opcode generated during PHP script parsing and execution by the Zend engine. If you are using APC 3.1.9 and you are using the default configuration you might run into the error where most PHP requests will return a warning message "PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0"
Zyxware default image2
| 2 min read
Sometimes we get requests to update Drupal sites and get it done in less than 5 hours. If we take the Drupal update through the full fail-safe set of steps for Drupal updates we will never be able to complete updates in less than 5 hours on a site we don't maintain. For such sites when the cost of the site going down may not be too high for the site owner it might not be too big an issue if the update is run on a hit or miss approach. We normally do not recommend such an approach but this should work on most small sites without any issues.