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 homepage into a file: <?php $ch = cURL_init(“”); $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 = ‘’; $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