Category Archives: PHP

How to get the near by cities in database using latitude/longitude

If you want to found near by city or near by latitute / langitute, first you create the MySQL table with lat and lng attributes. Your table should also have an id attribute to serve as the primary key. INSERT INTO markers (name, lat, lng) VALUES (‘Delhi’,’28.7041′,’77.1025′); INSERT INTO markers (name, lat, lng) VALUES (‘Noida’,’28.5355′,’77.3910′);… Read More »

Category: PHP

PHP Class Tutorial: Working with Methods

About the concepts of OOP in PHP5 from basics to very advanced level. We have learned about the class basic and public class properties in our previous tutorials. Today i am going to write about the basics of class methods. “Class properties allow your objects to store data and class methods allow your objects to… Read More »

Category: PHP

Using variables in CSS style sheets

One advantage of CSS is that your styles can be kept in a separate file from the pages that use them. This is simply a text file that ends with the .css suffix such as style.css. The suffix tells the server to treat the contents of the file as CSS. Unfortunately, the CSS standard doesn’t… Read More »

Category: PHP

Interfaces Abstract Classes and the Adapter Pattern

PHP 5 made significant improvements on the Object Orientated programming model of PHP 4 bringing it more in line with languages such as Visual Basic .NET and Java. The improved object model in PHP 5 makes developing applications using OOP much easier and gives you the programmer, greater flexibility. The first features new to PHP… Read More »

Category: PHP

Remove a Query String Key=>Value using PHP

I needed to find a PHP function that would allow me to remove keys (and their values) easily and reliably. /* the function */ function remove_querystring_var($url, $key) {   $url = preg_replace(‘/(.*)(?|&)’ . $key . ‘=[^&]+?(&)(.*)/i’, ‘$1$2$4’, $url . ‘&’);   $url = substr($url, 0, -1);   return $url; }

Category: PHP

The PHP Class with Dynamic Functions

class Record {     /* record information will be held in here */   private $info;     /* constructor */   function Record($record_array) {     $this->info = $record_array;   }     /* dynamic function server */   function __call($method,$arguments) {     $meth = $this->from_camel_case(substr($method,3,strlen($method)-3));     return array_key_exists($meth,$this->info) ? $this->info[$meth] : false;  … Read More »

Category: PHP

Php Writing to csv file

In this code am taking in a variable from a dynamic form($search). The variable is 10 random unique numbers. It was put into the form from a text/csv file. In this I need to write each line of the text/csv file into an array except the $search number, delete the contents of the file &… Read More »

Category: PHP

PHP Class Tutorial: Working with Methods

Class properties allow your objects to store data and class methods allow your objects to perform tasks. What are Class Methods Methods are special functions declared within a class. As you might expect, a method declaration resembles a function declaration. The function keyword precedes a method name, followed by an optional list of argument variables… Read More »

Category: PHP

PHP Exception Handling

What is an Exception With PHP 5 came a new object oriented way of dealing with errors. Exception handling is used to change the normal flow of the code execution if a specified error (exceptional) condition occurs. This condition is called an exception. This is what normally happens when an exception is triggered: The current… Read More »

Category: PHP

Introduction to PHP5 OOPS Features

PHP5 has made a lot of improvements as regarding OOPS is concerned. Although it has not been up to the mark with the likes of Java, .NET and C++; but when compared to PHP4, PHP5 has made significant improvements. In this post, I propose to cover the following topics: About PHP5 Future of PHP New… Read More »

Category: PHP