Archive

- Posts Tagged ‘PHP Script’

Filter/Edit CSV (Comma Separated Value) Data

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.… (Continue)

Get User Defined Constants in PHP

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… (Continue)

Handling File Read/write Concurrency Problem in PHP

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… (Continue)

PHP require/include and relative path error

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… (Continue)

Getting all Parent Folders of a Folder and File

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.… (Continue)

Online HTML Characters Encoding Tool for Script posting

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… (Continue)

Get All Included Files in PHP

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… (Continue)

How to Set Default File Path for Include Files?

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… (Continue)

Getting Visitors IP Address in PHP

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… (Continue)

Permanent 301 Redirect, using HTML and PHP

Yes, its true. You can 301 redirect using META HTML tag according to Sebastian. He says, Yahoo and Google accept it as 301 redirect. Though, it must be least preferred method. Using server side script or Server redirect (apache) is preferred method. HTML 301 Permanent Redirect: <html> <head> <title> --Title… (Continue)