Featured
-
Top 5 Features That Make Laravel the Best PHP Framework for Development
Laravel is a free open source Web Framework of PHP
by abhishek.tiwari.458 -
Best 5 Lightweight PHP Frameworks for REST APIs Development
Are you ready to develop the Rest AP
by ankur.kumar -
PHP: Full-Stack Framework vs Micro Framework
A web framework can be described as a software fra
by ankit.bhatia -
How to get facebook profile picture by Facebook App
If you would like to get your profile picture in f
by vivek.rastogi -
Creating RESTful API in cakephp
This tutorial will help you to learn how to create
by pushpendra.rawat
Tags
Stopping MySQL injection using Core PHP
What is SQL Injection?
According to WIKIPEDIA:
SQL injection is a code injection technique that exploits a security vulnerability occurring in the database layer of an application.
A SQL injection attack exploits security vulner...
Swap two variables value without using third variable in php
Here is a method. How to swap two variables value without using third variable and temp variable.
$a = 3;
$b = 2;
$a = $a + $b; // 3 + 2 = 5
$b = $a - $b; // 5 - 2 = 3
$a = $a - $b; // 5 - 3 = 2
print $a;
print $b;
Output:
2
3
How to configure database in Codeigniter
Hello Readers,
In order to create any web application using Codeigniter framework or any other PHP framework we need to configure database .
We have the database file inside application folder of a Codeigniter framework , inside application...
How to Install CodeIgniter in ubuntu
CodeIgniter can be installed in four easy steps on your ubuntu system:
1- Download CodeIgniter package and Unzip. Download link http://www.codeigniter.com/download
2-Upload the CodeIgniter folders and files to your server. Normally the inde...
12 Reasons to Choose PHP For Developing Website in 2015
Simplicity
As we all know that PHP is quite similar to languages like Pearl and C, and it is extremely easy-to-use and learn that becomes the most beneficial thing about this wonderful language for programming.
Any person no matter from whi...
REST API in joomla 3.4 with SLIM Framework PART 2
Flowing on from REST API in joomla 3.4 with SLIM Framework PART 1 it's time to to use the real power of Slim Framework. In this second part of tutorial series , we will use SLIM Framework in Joomla way of style to create powerful API.
As we le...
How to Use Mandrill SMTP in LARAVEL 4?
Using Mandrill SMTP in LARAVEL4 is easy to use by following below changes in cofig/mail.php
return array(
/*
|--------------------------------------------------------------------------
| Mail Driver
|---------------------...
How to use IN condition in find query in yii
Below code will help you to use IN condition in find query in yii-
$conditionsArray=array(1,2,3);
$criteria->addInCondition("userid", $conditionsArray);
$postdetails = Post::model()->findAll($criteria);
Creating Web Services with PHP and SOAP
What is SOAP??
SOAP stands for Simple Object Access Protocol. SOAP uses HTTP request for intraction between programs. Because of HTTP request is supported by all servers and browsers, that's why it is a best way to communicate between applicat...
Create Update, Delete and Insert Functions
Hello,
Here I am writing the code to create update, insert and delete functions so that we can use it the same functions anywhere in the project.
<?php
// function to insert data
function insert($table = "", $fieldsArray = array()) {...
Logger class in PHP
Hi
This is a simple application logging class which you can use in your PHP project. It currently provides two methods, one for logging messages and another to log a dump with an optional message. I will add the streams support and stack tra...
How to import csv file into mysql database in php
To Import csv file into mysql database using php script follow the below code:
For example: I have a .csv file data with this formate:-
(1) Indresh Singh, indresh@abc.com, 12345
(2) mukul kant, mukul.kant@abc.com, 12345
To insert ...
How to Make Database Association on Selected Pages In Cakephp
If you want to make Database Association on Selected Pages In Cakephp follow the below steps,
Below code can set association where it require and you can also reduce unnecessary queries firing to database.
Make function in your model and ...
Paypal: Create Recurring Payments Profile Working Code
This code use to deduct amount automatically from paypal buyers account. It is something like advance payment mode. If user agree with automatically deduction when he / she paying through paypal then amount will deduct according to billing period...
Remove .php, .html,.htm extension from website url.
Hello ,
I am sharing here how you can remove .php extension from Url of your website. here are the following steps:-
Create a .htaccess file in project directory.
Suppose you have to remove the .php extension from a PHP file for example ...
SMTP Configuration of server
If you are using some other server like godaddy or some other server for that you need to put the settings of that particular server in its setting. I am sharing the settings for godaddy server.
$mail = new PHPMailer();
$mail->IsSM...
How to download file using PHP script
We use this script to download a file from a given define file path location
In this script we are using two variable:
1:) $fileName // for file name with path.
2:)$title //for file name changed in you given title name.
<?...
How to integrate MobBill Mobile payments for Video, Ringtones etc
Hi All,
Here I am sharing how to implement MobBill Mobile payments, for this follow the steps below :-
Step 1 -> You need to login into the link http://merchant.mobbill.com/insight/login/auth and create your account.
Step 2 -> Now...
Create custom component in Joomla 1.5
Sometimes, when we are working on CMS like Joomla, Drupal etc, we have such requirements for which we need to build our own component. On that component, we can add our logics for development.
Here are some basic steps to create you own Joomla...
Steps to create custom plugin in Joomla 1.5
There are some core plugins availabe in Joomla project for e.g. System, User, Search, authentication, content etc. Plugins provide a function which are associated with specific event trigger.
In one of my project, I had a requirement to add pa...
How to Create Simple Html File Through PHP Script
This tutorial show's how we can create a simple Html file through PHP script.
if($filename == ''){
$filename = 'demo.html';
$writefile = ($filename , 'w');
$content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict...
How to Make a new CSV File Through PHP Script.
This tutorial show's how to create a new CSV file through PHP script.
This script is more helpful for php developer to create a new CSV file in array formate.
function functionname (parameter)
{
if (($handle = fopen("$data", "r")) !== ...
Code to validate ISBN10 or ISBN13
We seldom need a code to check whether the ISBN of book we are trying to search is a valid ISBN or not. So as to validate a provided ISBN we can use the below code for ISBN10 and ISBN13 respectively :
Code for checking validity of ISBN10 :
...
Unexpected bheaviour of in_array in PHP
We have an associative array where its values are all Boolean and if we search for a string, we got true.
Lets see an example.
<?php
$array = array(
'count' => 1,
'references' => 0,
'ghosts' => 1
);
var_dump...
Laravel Framework
Recently Laravel framework has been launched in the market as I am not familiar with it, because still I have not worked on this framework but it seems to be one of the best MVC framework, below link provides you an average of mostly used/popular...
Passing extra data with push notification
Sometime we do need to send additional data while sending Push-notification on iPhone , this can be easily achieved by adding following line to your code. But one should keep in mind that apple does have a limitation of 144 character while sendin...
How to connect to your MySQL database from a PHP Script
Create simple Mysql connection with the help of PHP code
<?php
$hostname = 'localhost'; //define the hostname here
$username = 'root'; //define the username here
$password = ' '; ...
Flaws of "and" and "or" operators in PHP
Today, When I was doing some programming stuffs and I found out that there is serious flaw in the and , or logical operator of PHP.
Im not talking about the symbol || and && logical operator. Im talking about the and and or logical op...
Solution for error 'The requested address '/' was not found on this server' in cake PHP
If anyone face the error 'The requested address '/' was not found on this server' in cakePHP, then try these two steps:-
Add function date_default_timezone_set() somewhere in you cake/app folder.
If above solution not works then place date_...
Using Email or Username to login with auth in cakephp
We seldom need to login into application using Email or Username while using Auth with Cakephp. To achieve this we either need to write customized Auth component or we can achieve the same with the following code :
public function validateUs...
Form submit in javascript
I would like to share an interesting feature that I found as I was trying to submit form through JavaScript.
If you are trying to "form.submit()" through javascript and any form elements present with the name of "submit" in it, then in that case...
Time Difference between two timezones - Php
Many a times we need to take out time difference between two time zone using Date class in php. We can use the following code :-
$timeZone = ['Any Timezone'];
$default = date("Y-m-d h:i:s A");// UTC
$dateTimeZone =...
How to download any CSV file while working with PHP
/* Header file to includes.
fopen is use to open a file in write mode here.
fputcsv function is use to output the CSV file having the name of columns and data coming from database. */
header('Content-Type: text/csv; charset=utf-8');
header('...
Date difference between two timezones in PHP
Here is a short function to get the difference between two timezones in PHP:-
function diff(){
$date1 = "2014-02-27T20:00:00+04:00";
$date2 = "2014-02-28T07:20:00+08:00";
$diff = abs(strtotime($date2) - strtotime($date1));...
Get timezone from address or zipcode or address
Hi,
We can get user's timezone if we have only address or zipcode of that user. First of all we need to get latitude and longitude then using these lat and long we can get timezone. However this is 2 step approach but it is much accurate becau...
How to create profile page hiding controller and action name in yii
How to create profile page hiding controller and action name in yii
In url manager add this line
'<username:\w+>'=>'site/index',
username will be the parameter for name or id and site is controller name
and the url will be...
Image Rotation by image magic
Creating image rotation using Image magic by command line.
Some time image taken from iphone when uploaded on the website gets rotated .We can easily find that the image is rotated and can rotate is back by using the following code.
$rot...
Bind Model in cakephp
In one of my project I have two table with simple relation
Division (id, title) - hasMany Staff
Staff (id, division_id, name, jobtitle)
So. Now I need to get some info like: I need to get all Staff where birthday today, and get r...
Get the title and meta tags from a url in php
To get the title and meta tags from a website you can use the following code :
<html>
<head>
</head>
<body>
<?php
function getTitle($Url){
$str = file_get_contents($Url);
if(str...
Scrapping - get Select option values and text via simple html dom
Here is the working example to get select box option value and text via Simple html dom.
I assume that you have already included simple_html_dom file and have html content in $content variable
$html = new simple_html_dom(); // Creating htm...
What Is The Diffrence Between Do And Do While Loop
The Main Difference Between Do And Do While Loop Is :-
Do while Loop :- If we use "Do While" at least one time execute the loop and then check the Condition.
While Loop:- When we Use "While" then firstly check the condition after execute ...
Snapshot of any website from its URL
Get the snapshot of any website in php without writting a script
<html>
<head>
<!--[if IE]>
<style>
#frame {
zoom: 0.2;
}
</style>
<![endif]-->
</head>
<body>
<div class="test...
Getting the Code of any site using php script
Open the code view of any site :
<?php
$lines = file('http://www.whoznext.com/'); //Site url
foreach ($lines as $line_num => $line) { // iterate through each line
echo "Line #{$line_num} : " . htmlspecialchars($line...
How to inherit the properties and methods of base class to the child class in php
<?php
class data<br>
{<br>
public $firstno;<br>
public $secondno;<br>
public function getData($fno,$sno)<br>
{<br>
$this->firstno=$fno;<br>
$t...
Passing an array to the URL
Sometime you may need to pass the array in the url.
You can do this as following:
<?php
$array["a"] = "A";
$array["b"] = "B";
$array["c"] = "C";
$array["d"] = "D";
$str = serialize($array);
$strenc = urlencode($str);
print $str ....
How to make UL/LI tree from a normal array
We usally wants to male a ul/li tree from an array having parent id within each individual record :
$subjecttopic=Array
(
[0] => Array
(
[id] => 52b28146f484a5a410000029
[name] => Addtion
...
Using Ternary operator instead of If/Else in Php
Evaluating If Else statements is very common in programming paradigm. But 'If Else' statements are long and they can be easily replaced by simply using Ternary operators. Here is a tutorial on the usage of ternary operators and their implementati...
Extract method in PHP
Sometime we may need to use the same variable name that you are using in the query or simply in an associative array.
Lets say you have an associative array :
$arr = array( 'totalLimit' => 50, 'limit' => 10 );
The usually what we...
Using HeroDocs in php
Herodocs are useful for multi-line strings and avoiding quoting issues. It prevents from escapinging of characters in php
EX1 )
$sql = <<<SQL
select *
from TABLE_NAME
where id =1
and product_name = "widgets"
SQL;
O/...
How to create a class and object in php
class rect
{
public $length=0;
public $width=0;
public $area=0;
public function getData()
{
$this->length=10;
$this->width=20;
}
public function area()
{
$this->area = $this->leng...