Sometimes you need to avoid using cURL for getting external web content for any reasons. You’re lucky that PHP has some built-in functions that allow you to get data from the Web without cURL. But if you are using default values, there is no option to set the timeout for a operation and it’s sometimes annoying. In order… Read More »
If you have used Hesk before, you must have mentioned that all links that were posted by users at the time of ticlet creation/reply were opening in new tabs. If you decide to update to 2.5.2 (I was using version 2.3 before), you will notice that all links will be opening in the current tab. If you want… Read More »
After another PHP recompilation I’ve started getting the following error while trying to access SSL websites with cURL: 56 SSL read: error:140940E5:SSL routines:SSL3_READ_BYTES:ssl handshake failure, errno 0 What does this mean and how to solve this issue? This means your cURL installation is trying to use the wrong number of SSL protocol. All you need to resolve this… Read More »
If you have an array with duplicate values, sometimes you might need to show only non-unique elements. Here is a short code in PHP that will allow you to do this. <? $arr=array_map(“trim”, file(“file.txt”)); $nonuniq=array_unique(array_diff_assoc($arr, array_unique($arr))); ?> This will return unique array of duplicates. If you need to show all duplicated values, use this code. <? $arr=array_map(“trim”, file(“file.txt”));… Read More »
Just wanted to paste a PHP solution for a Paypal refund. It was found on Paypal official site, but I spent some time to get it. [code type=php] [/code]
You can count the number of substring occurrences using Regexp-based functions, but if you don’t want to deal with them, that seems to be the fastest option for case insensitive substr_count.
Today I had to fix a script that sends an e-mail using PHPMailer. Here is the intital code: $mail->From = “firstname.lastname@example.org”; $mail->FromName = “Lampdocs.com”; $mail->AddAddress(“email@example.com”); $mail->AddReplyTo($webmaster_email, “Lampdocs.com”); $mail->WordWrap = 70; // set word wrap $mail->IsHTML(true); // send as HTML $mail->Subject = “Order from New Paypal Address”; $mail->Body = $milo; //HTML Body $mail->Send(); I had to send 2 different… Read More »
Since cookies are small files that are stored on user computers, you don’t have the ability to remove them as files. But you can delete them using a simple PHP script.
Recently I had to deal with Twitter avatar upload for a Twitter application. Everything went very well, but when I have prepared everything for the upload query, the only server response I got was Error 417. Since I used cURL, I tried to deal with different headers, but with no luck at all. I found the solution at… Read More »
If you need to work with Russian text in PHP, you may notice that functions that are related to CaSe are not working as expected. I mean strtolower, strtouper, ucwords, and so on. In order to get what you need I suggest to use mb_convert functions. Here is the example: You can check reference table for functions, I… Read More »