Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- PHP



  PHP's Output Buffering

While profiling our application I came across a a rather strange memory usage by the ob_start() function. We do use ob_start() quite a bit to defer output of data, which is a common thing in many applications. What was unusual is that 16 calls to ob_start() up chewing through almost 700kb of memory, given that the data being buffered rarely exceeds 1-2kb, this was quite unusual. I started looking at the C code of the ob_start() function and found this interesting bit of code inside php_sta...

   PHP,Memory,ob_start(),source,40kB     2011-12-08 10:20:32

  Configure a PHP web server on CentOS

Are you used to use cPanel or Plesk on VPS for your PHP website management? If for some reason you don't want to use them? What can you do? How do you maintain your website? How do you access Emails, use FTP to upload files or use phpMyAdmin to manage your databases? You may need to configure all these services yourself on a VPS without cPanel or Plesk or other similar apps.But to configure all these services on a Linux server is not an easy job. You may spend many nights but still fail to get s...

   Cron,Linux,CentOS,Email,FTP,MySQL     2012-07-08 06:01:56

  Resolving error "SSL certificate problem: self signed certificate in certificate chain"

In a PHP application, cURL is frequently used to make connection to remote server to request some resource. It can be used to transfer data with different protocols such as HTTP, HTTPS, FTP etc. While using cURL in PHP, someone may get an error with message similar to "SSL certificate problem: self signed certificate in certificate chain". This may happen when cURL tries to make a SSL connection server and the server returns a server certificate which is self-signed and it's not trusted by the c...

   PHP,SSL,CURL,TWILIO     2016-06-26 07:17:23

  Useful functions to provide secure PHP application

Security is a very important aspect of programming. There are many functions or modules in any kind of real programming language providing security functionalities  In modern websites, we may often get inputs form users all around the world.There is a famous saying which says that never trust user input. So in web programming languages, we will often see functions which will guarantee the security of the data input from users. Today we will cover some of these functions in the most famous o...

   PHP,security,SQL Injection,XSS,AJAX     2014-10-30 04:21:59

  php://input in PHP

When using xml-rpc, server side will get the data from client with php://input method instead of $_POST. Hence today we will discuss php://input. PHP official manual has below explanation to php://input: “php://input allows you to read raw POST data. It is a less memory intensive alternative to $HTTP_RAW_POST_DATA and does not need any special php.ini directives. php://input is not available with enctype=”multipart/form-data”. Here we und...

   php://input, IO, input     2013-02-25 20:43:00

  Resolve high CPU usage issue caused by file_get_contents in PHP

Sometimes a Linux server which runs Nginx + PHP-CGI(php-fpm) web service may experience sudden system load increase and the CPU usage is around 100% for many php-cgi processes when checking with top command. If this happens, file_get_contents may be the cause if it's used in the PHP script. In lots of web applications, normally there are lots of API requests based on HTTP. Many PHP developers like to use file_get_contents("http://example.com/") to get the API response because it's simple to...

   PHP,FILE_GET_CONTENTS,PHP-CGI     2018-11-09 21:35:00

  Using JSON in PHP

Currently JSON has become one of the most popular data exchange formats. Many website APIs support it. Since PHP 5.2, PHP provides json_encode() and json_decode() method to handle JSON encoding and decoding.1. json_encode()This function is used to transform array and objects to JSON format. First let's look one array example.        $arr = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);   echo json_encode($arr);the result is{"a":1,"b"...

   JSON,PHP,json_decode(0,json_encode()     2012-05-06 06:04:42

  Output a file with HTTP range header in PHP

When downloading a large file, we may encounter some network issues which causes download termination and only part of the file is downloaded. When the network connection resumes next time, we may need to redownload the file again from the beginning. In order to save bandwidth, http provides a Range parameter in its header which can control the file transfer flow. With the range parameter in the header, we can resume the download from where we stop. Here is a piece of PHP code snippet which uses...

   PHP, range,http, file transfer     2013-01-09 05:55:05

  Handy PHP functions should be in your toolkit

When developing projects, there are always some common work should be accomplished, for example, encrption/decryption, get IP. As a PHP developer, you should have a list of the handy functions in your toolkit so that you can pick up in every project you work on. Here is a summary of some handy PHP functions. 1. PHP encryption/decryption Encryption/decryption can be used when storing user confidential information such as passwords. Below function uses base64 and MD5 to accomplish encryption/decry...

   PHP,function,real IP,SQL injection     2014-12-06 08:46:08

  Send email using PHPMailer on GoDaddy hosting

According to PHPMailer troubleshooting guide, GoDaddy has a very strict rule on sending email using PHPMailer. Popular US hosting provider GoDaddy imposes very strict (to the point of becoming almost useless) constraints on sending an email. They block outbound SMTP to ports 25, 465 and 587 to all servers except their own. This problem is the subject of many frustrating questions on Stack Overflow. If you find your script works on your local machine, but not when you upload it to GoDaddy, ...

   PHP,PHPMAILER,GODADDY     2018-11-16 08:28:55