Archive

Posts Tagged ‘PHP Script’

PHP + CURL: Get Returned Content Mime Type

Jul 22nd, 2010

Did you ever tried to get mime type of the returned content in CURL! I was writing a small application for something and thought to know the Content-Type (mime type) of the response data returned by CURL’s exec(). Before thinking of anything else, I habitually started Goggling and found this… READ MORE

Filter/Edit CSV (Comma Separated Value) Data

Jul 16th, 2010

CSV is very common format for data interchange. It is not as famous as XML and JSON but it is always easy to work with. CSV file can be opened directly in MS Excel and readable in any text editor. It does not take as much space as XML takes.… READ MORE

Get User Defined Constants in PHP

Jul 15th, 2010

PHP function – get_defined_constants()  gives all the constants defined in current scope.  It can be CORE Constants, extensions defined constants and user defined constants. As a developer you may be interested in all defined constants or user defined constants at a time. As the total number of constants printed on… READ MORE

Handling File Read/write Concurrency Problem in PHP

Feb 23rd, 2010

Recently I need to use file for caching little bit of data. Then I thought of concurrency problem can arise in File based structure due to read/write issue. For small data and that also if  not so useful , usage of Database can be avoided. Though Database can handle any… READ MORE

PHP require/include and relative path error

Jan 7th, 2010

It is little difficult to get the right path in PHP sometime. PHP gets the path based on top page. To get the right path two functions are very useful – getcwd() and realpath(). To get what PHP is understanding of your supplied path for require/include, use realpath(). It will… READ MORE

Getting all Parent Folders of a Folder and File

Dec 26th, 2009

I need to get all the parent folders of a File for a work. I searched on net to find easy solution for this and also to find some tips for my work. As, my work was heavily dependent on this logic, so I have given some time to it.… READ MORE

Online HTML Characters Encoding Tool for Script posting

Dec 13th, 2009

Here is an online HTML characters encoding tool I have created for those who post script on a blog or webpage. It will convert all the <, >, ‘ and ” characters to html entities.
I was doing it manually everytime by searching < and replacing it with &gt; and… READ MORE

Get All Included Files in PHP

Nov 15th, 2009

Want to know how many files are included in the current PHP script? Multiple files can be included in a single include file on a PHP script using include(), include_once(), require() and require_once().
- A.php
includes B.php
B.php
includes C.php, D.php etc
Now, file1.php can have multiple files and few… READ MORE

How to Set Default File Path for Include Files?

Nov 15th, 2009

Included/required files will be searched in include path when not found in current directory or given path. This Path will act like a default path for all files included using include, require, require_once and include_once.
For lots of files residing in a deep directory and you want to set include… READ MORE

Getting Visitors IP Address in PHP

Oct 26th, 2009

There are plethora of variables which can hold the Visitor IP address. One such variable is $_SERVER["REMOTE_ADDR"].
REMOTE_ADDR looks more close to our task as it has ‘remote’ inside it. But this variable can hold the private LAN IP address of the client machine’s server network and which is not… READ MORE