Tag Archives: php
How to force page not to be cached in PHP

header function header(’Expires: Fri, 01 Jan 1990 00:00:00 GMT’); header(’Cache-Control: no-store, no-cache, must-revalidate, max-age=0, pre-check=0, post-check=0’); header(’Pragma: no-cache’); //…header(‘Expires: Fri,…

Parse JSON data in PHP

json_decode $data='{"id":1,"firstname":"george","lastname":"karpouzas","emails":["abcd@gmail.com","abcd@yahoo.com"]}’; $obj=json_decode($data); echo ‘ID: <b>’.$obj->id.'</b><br>’; echo ‘First name: <b>’.$obj->firstname.'</b><br>’; echo ‘Last name: <b>’.$obj->lastname.'</b><br>’; echo ‘Email 1: <b>’.$obj->emails[0].'</b><br>’; echo ‘Email…

Create JSON data in PHP

json_encode Code: $data = array (’id’=>1, ‘firstname’=>’george’, ‘lastname’=>’karpouzas’, ’emails’=>array(’abcd@gmail.com’,’abcd@yahoo.com’));   echo json_encode($data);$data = array (‘id’=>1, ‘firstname’=>’george’, ‘lastname’=>’karpouzas’, ’emails’=>array(‘abcd@gmail.com’,’abcd@yahoo.com’)); echo json_encode($data);…

List files in directory – PHP

$dir = ‘/path/to/dir/’; if(is_dir($dir)) { if($handle = opendir($dir)) { while(($file = readdir($handle)) !== false) { if($file != "." && $file…

Base64 encode and decode string in PHP

Base64 is a group of similar encoding schemes that represent binary data in an ASCII string format by translating it…

Send email with php

Sending email with PHP and build-in function mail. $to = "example@gmail.com"; $subject = "Test"; $body = "<b>Body</b> <i>of your message</i><br>";…

Set PHP configuration options in Apache using directives

Apache directives to change the PHP configuration: php_value name value Sets the value of the specified directive. php_flag name on|off…

require VS include & require_once VS include_once in PHP

include() The include() function includes and evaluates the file during the execution of the script. Files are included based on…

Simple Session Management Class in PHP

Let’s see a simple session wrapper class implemented using singleton pattern: 1 2 3 4 5 6 7 8 9…

How To Write A Simple PHP Web Service

Web Services are Everywhere! Let’s see how easy it is to create one using PHP, MySQL and XML! First of…

Previous Page · Next Page