You are here
php curl request Basic PHP PHP PHP Coding 

PHP cURL Requests

PHP cURL Requests PHP cURL Requests :  A simple introduction to GET and POST requests over HTTP. The idea behind the cURL functions is to initialize a cURL session using the cURL_init(), then  set all your options for the transfer via the cURL_setopt(), then execute the session with the cURL_exec() and then  finish off the session using the cURL_close(). Example of cURL functions to fetch the example.com homepage into a file: <?php $ch = cURL_init(“http://www.example.com/”); $fp = fopen(“example_homepage.txt”, “w”); cURL_setopt($ch, cURLOPT_FILE, $fp); cURL_setopt($ch, cURLOPT_HEADER, 0); cURL_exec($ch); cURL_close($ch); fclose($fp); ?>   All cURL Functions…

Read More
jquery contact form with ajax and php PHP PHP Coding 

How to Create a jQuery Contact Form with Ajax and PHP

jQuery Contact Form with Ajax and PHP. We have created a simple HTML form with four fields Name, Email, Gender, Bacon and check me.   HTML : – Html to build the structure of your contact form PHP : – Use PHP to process the data to make  and PHP mail() function to be used to send email. Ajax & Jquery : – Through jQuery user can submit the forms and you can put validation using jquery. HTML Form  (contact-form.html): <form method=’post’ action=’/contact.php’> Name: <input type=’text’ name=’name’ required><br> Email: <input type=’email’…

Read More
uploading file with php Basic PHP PHP PHP Coding 

Uploading Files with PHP

Uploading Files with PHP How to upload files on server using a Simple HTML form and PHP. You can upload any type of file like images, videos, ZIP files, Office documents file, PDFs and other supported file types. Crating a HTML form to upload the file : <form method=’post’ enctype=’multipart/form-data’ action=’upload.php’> File: <input type=’file’ name=’file_upload’> <input type=’submit’> </form>   PHP SCRIPT to upload file : <?php // Check for errors if($_FILES[‘file_upload’][‘error’] > 0){ die(‘An error ocurred when uploading.’); } if(!getimagesize($_FILES[‘file_upload’][‘tmp_name’])){ die(‘Please ensure you are uploading an image.’); } // Check…

Read More

Simple PHP script to send Android Push Notification, iOS Push Notification and Windows Phone 8 Push Notification

PushNotifications.php <?php // Server file class PushNotifications { // (Android)API access key from Google API’s Console. private static $API_ACCESS_KEY = ‘AIzaSyDG3fYAj1uW7VB-wejaMJyJXiO5JagAsYI’; // (iOS) Private key’s passphrase. private static $passphrase = ‘joashp’; // (Windows Phone 8) The name of our push channel. private static $channelName = “joashp”; // Change the above three vriables as per your app. public function __construct() { exit(‘Init function is not allowed’); } // Sends Push notification for Android users public function android($data, $reg_id) { $url = ‘https://android.googleapis.com/gcm/send’; $message = array( ‘title’ => $data[‘mtitle’], ‘message’ => $data[‘mdesc’],…

Read More

iOS Push Notifications with PHP

Introduction Sending notifications to an iOS Application can enhance the experience exponentially for users, also it allows you to deliver key data easily. However, actually sending the push notification to users can be a bit tedious at times, and at times confusing. You need to ensure that you pack your integers, and times correctly – failing to do this and you’ll probably get an unhelpful status from Apple. The APNS Using the APNS (Apple Push Notification Service) requires a bit of pre-configuration initially, you’ll need to download some certificates from…

Read More
php-magic-methods Object Oriented PHP PHP 

OOPS Magic Methods

Magic Methods The function names __construct, __destruct (see Constructors and Destructors), __call, __get, __set, __isset, __unset (see Overloading), __sleep, __wakeup, __toString, __set_state, __clone and __autoloadare magical in PHP classes. You cannot have functions with these names in any of your classes unless you want the magic functionality associated with them. __sleep and __wakeup serialize() checks if your class has a function with the magic name __sleep. If so, that function is executed prior to any serialization. It can clean up the object and is supposed to return an array with…

Read More
design-patterns-php PHP PHP Design Patterns Tutorial 

PHP Design Patterns

Design Patterns : Patterns are ways to describe best practices and good designs. They show a flexible solution to common programming problems.   Factory Pattern : The Factory pattern allows for the instantiation of objects at runtime. It is called a Factory Pattern since it is responsible for “manufacturing” an object. A Parameterized Factory receives the name of the class to instantiate as argument.   Example : <?php class Example { // The parameterized factory method public static function factory($type) { if (include_once ‘Drivers/’ . $type . ‘.php’) { $classname…

Read More
classes and objects in php Object Oriented PHP PHP Tutorial 

Classes and Objects in PHP

Class : Every class definition begins with the keyword class, followed by a class name, which can be any name that isn’t a reserved word in PHP. Followed by a pair of curly braces, which contains the definition of the classes members and methods. A pseudo-variable, $this is available when a method is called from within an object context. $this is a reference to the calling object (usually the object to which the method belongs, but can be another object, if the method is called statically from the context of…

Read More
php-introduction Basic PHP PHP Tutorial 

Introduction to PHP

What is PHP PHP Stands for HyperText Preprocessor PHP is the web development language written by and for web developers It was originally named as Personal Home Page Tools Other name for PHP is professional home page It is server side script which can be embedded in HTML or used as a standalon binary.   History of PHP Rasmus Lerdrof is the creator of the PHP language The first part of PHP was developed in 1994   Common uses of PHP The PHP allow to web developers and programmers to…

Read More
ajax-image-upload-feature PHP PHP Coding 

Ajax Image Upload using PHP & Jquery without page refresh

Upload image without page refresh using Jquery, Ajax and PHP In this post we can learn how to upload Image using php and jquery. Through this script you can upload image without refereshing page and also preview the image file while uploading. These are the steps and procees to be used to upload file. 1) Include jquery library file on the top of the page under head tag. <script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js”></script> <script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/jquery.form/3.51/jquery.form.js”></script> 2) Write Some html script for image upload field and for image preview. <form id=”upload” method=”post”…

Read More