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
Create custom user login using AJAX in WordPress
Hello Reader,
If you want to create WordPress custom login using AJAX below example will help you.
You just need to follow the steps one by one.
1.) copy the below line and paste it to header,php file under </head> section.
<...
Create custom user signup using AJAX in WordPress
Hello Reader,
The below example will help you to create user custom sign-up using AJAX.
Please follow below steps to create WordPress custom sign-up.
1.) copy the below line and paste it to header,php file under section.
<script t...
How to use array_keys() function php.?
What does array_keys() function in php.?
The array_keys() function returns an array containing the keys.
Syntax of array_keys() function:
array_keys(array,value,strict)
So, there are three main Parameter of array_keys().
These are foll...
How can do caching in Core PHP?
To implement caching in core php follow the below steps : -
Step 1 - Firstly create a folder having write permission where we store the output of the page.
Step 2 - At the start of file, please check whether we have already stored any...
Send an email using Email Template in Zend Framework.
As we all knows email functionalities in websites is common and used in all web application. Either it is registration process or detail of any order, we always need to send an email to our valuable users and clients.
For sending the email usi...
Prevent SQL-injection in PHP
User can prevent SQL- injection in php by using given 3 ways.
Method1. By Using PHP inbuilt Functions.
$name = mysql_real_escape_string($_POST["name"]);
mysql_query("INSERT INTO users VALUES($name)");
Method 2. By Using MySqli instead...
What are Hooks in CakePHP ?
Hooks are the functions that we can call before and after doing any task in Models ( database related ). Like after finding data, before saving data etc.
e.g beforeSave(), afterSave(), beforeFind(), afterFind() etc.
<?php
class Classnam...
method for sanitizing user input with PHP?
Sanitize data means "Remove any illegal character from the data".
Best methods for sanitizing in php are given below.
Method 1 - Sanitize user-input when we are using Mysql Query.
For this case you have to use real_escape_string of mysql...
Save MySQL query results into a text or CSV file
Hello Readers!
MySQL provides an easy mechanism for writing the results of a select statement into a text file on the server.
Given a query such as
SELECT order_id,product_name,qty FROM orders
which returns three columns of data, t...
Importing a csv into mysql via command line
Hello Readers!
MySQL have this load data function, where we can insert data to a table from external files like csv, txt etc.
The process is quite simple, 1st lets login to mysql via terminal/console.
mysql -u root -p
Enters usernam...
lcfirst() and ucfirst() string functions in php
The string functions lcfirst() and ucfirst() are used in the cases when there is a need for manipulating your string first alphabet. These occurs when the string is like name or title.
lcfirst()
This function does the lowering of the first...
Upload CSV and Insert into Database Using PHP/MYSQL
Hello Readers !
We can simply upload upload CSV data into database by two simple ways.
Step 1 Data Base Connection
<?php
$db = mysq_connect("Database", "username", "password") or die("Could not connect.");
if(!$db)
die("n...
How to use array_flip() function php.?
Why use array_flip() function in php.?
The array_flip() function mainly used for exchanging all keys with their associated values in an array.
Syntax of array_flip() function:
array_flip(array)
You can take reference form below examp...
String Function In PHP
String function in php
To reverse a string
strrev- It is used to reverse a string.
<?php
echo strrev("Hello world!"); // outputs !dlrow olleH
?>
To search for a specific text in your string
strpos- it return the characte...
How to use array_fill() function php.?
Use of array_fill() function in php.
The array_fill() function is basically used for filling an array with values.
Syntax of array_fill() function: array_fill(index,number,value)
According to above syntax, there are three main Param...
Traits in PHP?
Traits in php are the mechanism for reusing the code in a single inheritance.
Trait is as similar as a class, but only focus to group functionality in a consistent way to fine grained.
We can not instantiate a Trait . It is for reducin...
How to use substr() function php ?
Definition of substr() function in php ?
The mainly use of The substr() function returns a component of a string.
Syntax of substr() function
substr(string,start,length)
You can see below example the use of substr() function.
&l...
How to join table in cakephp
Most of cakephp developer write custom query to join two table of database but cakephp provides best facility to join more than one two table in single query using association .
Let see an Example:-
SELECT *
FROM `messages`
INNER JOIN user...
How to style BuddyPress pages than a regular WordPress page
Hello Readers,
Most of the time when you work on the buddyPress, you wanted to style BuddyPress pages differently than a regular WordPress page, you need add a template file named buddypress.php to your themes directory and BuddyPress would us...
Buddypress Templates - how to customize buddypress pages?
Hello Readers,
Today we will discussed about BuddyPress template customization.
If you want customization to buddyPress template then you need to follow below steps.
1.) Need to adding a Child Theme if you haven't done so already.
2.)...
How to create custom taxonomy for post type page
Hello readers, today we will discuss "how you can add category for post type page".
When a user install the WordPress, user will only get category for "post type post".
If user want to add taxonomy or category for "post type page", then u...
How to filter Model assoceation data in cakephp
By using Containable Behavior we can filter model assoceation. we use 'Containable' keyword for use contain
we add this property in model
class User extends AppModel {
public $actsAs = array('Containable');
}
and we can use this ...
Constant in PHP
Constant value cannot be changed or undefined during the execution of script. By default constant is case-sensitive.
Constant cannot be defined by simple assignment, they may only be defined using the define() function.
Create a PHP Constant...
implode and explode string functions in php
Implode()
It is a string function which returns the Join array elements as a string.
The Implode() returns a string with elements of array arranged in a string in the same order.
example:
<?php
$str = array('Hello','World!...
How to use define() function php ?
What is define() function ?
The define() function basically use for creating a constant.
It depends on 3 parameters:
1-name-> this is the name of the constant.
2-value->value of the constant.
3-case_insensitive-> define co...
find and save the records by using cakePHP models
make a controller name Pagescontroller.php and paste the following below code
<?php
class PagesController extends AppController {
public $name = 'Pages';
/* Use Customer model */
public $uses = array('Customer');
...
How to use compact() Function in php ?
What is compact() Function ?
compact() Function is used for creating an array from variables and their values.
Syntax compact() Function:
compact(variable1,variable1,variable3....)
Note:If any strings that does not match variable name...
'Failed to open stream: Permission denied' error - Laravel
Some time when we want to access our public folder then we get the error "Failed to open stream: Permission denie' error - Laravel" . So when we get this error .Do not think much we have to clear our cache and just give permission to our folder a...
How to save data in CakePHP
This is a very simple application in cake php for saving the data into database. We can simple make it by making the database and connecting it to cake php.
After making the database and tables we can use this code for saving the data input in...
How to Upload File In PHP ?
File uploads is not difficult, it is easy to upload files or Images to the particular Folder. But before uploading the files ,you have to configure "php.ini" File. So, Check your php.ini file and verify the file_uploads directive is set On.
Sy...
substr_count() string function in php
The substr_count() in php is a string function which counts the no of times the sub string occurred in the string.
this function is case-sensitive.
the syntax of the function is as :
substr_count(string,substring,start,length)
Here , ...
How to handle default error in PHP
We can handle default error in PHP in a very simple way. This can be done by sending an error message with its filename, error line number and a message that describes the error to the browser.
Error handling plays an important role whenever we ...
Laravel: Load method in another controller without changing the url
We can load method in another controller without changing the url using Laravel.
If you are using Laravel 3 then we will define:
Controller::call('ApplesController@getSomething');
If We are using Larval 4.x then we will define:
$req...
strcmp string function in php
The strcmp is a string function in php which compares the two strings. strcmp is a binary-safe and case-sensitive function.This means the comparison is case sensitive.
The syntax of strcmp:
strcmp(string1,string2)
Here, the string1 is...
Get Multiple Parameters with same name from a URL in PHP
Hello readers, Below example will help you to "Get Multiple Parameters with same name from a URL in PHP".
<?php
$query = explode('&', $_SERVER['QUERY_STRING']);
$params = array();
foreach( $query as $param )
{
list($name, $v...
How to autoload 'libraries' in laravel 4
We can easily auto-load libraries in Laravel 4.x by using namespaces in our application. Then put all libraries you code under that namespace.
Suppose our directory structure would then be:
libraries
Myapp
Search (note directo...
Handling data in a PHP JSON
Hello readers, today we discuss about "Handling data in a PHP JSON Object".
There are many tutorials available for handling JSON using PHP, but problem with most of them is they don't help more than organizing an assortment towards json_encod...
How to use current() function and end() function in php ?
why use current() function:
current() returns the value of the current element in an array:
Syntax of current() function:
current(array)
why use end() function:
end() returns the value of the last element in an array:
Syntax of...
Difference between echo, print and print_r in php
The echo and print are similar ones as they are not a functions they are the language constructs.
echo
The echo as a language construct it outputs one or more strings. The echo has a void data type.As it is a construct and not a function s...
How to use each() function in php ?
What is the work of each() function ?
PHP each() function mainly Return the current key and value pair from an array.
Syntax of each() function:
each(array_name)
You can take reference form below example to use of each() function.
...
How to count the number of occurrences of values in an array
There is a function array_count_values() in PHP which counts the frequency of occurrences of all values of an array. The function returns an associative array with original values as keys and the number of occurrences as values.
Syntax: array_...
How to use strrev() function in Php?
What is the strrev() function?
strrev() function is uses for reversing a string. strrev() function is also used for reversing a number.
In the given below example you can easily understand the use of strrev() function
<?php
//here c...
How to use list() function in php ?
What is the use of list() function?
The list() function is used to assign values to a list of variables in one operation. list() function basically works on numerical arrays.
Syntax of list() function:-
list(variable1,variable2,variable3...
Push Notification for iphone using laravel 4.x
There are few steps which we have to follow to implement Push Notification.
Step 1: First we will write the api to get token and device type . Here is the controller code of push notification.
public function pushNotification() {
$...
Push Notification for Android using Laravel 4.x
There are few steps which we have to follow to implement Push Notification.
Step 1: First we will write the api to get token and device type . Here is the controller code of push notification.
public function pushNotification() {
$...
How to create form in CakePHP ?
We can create form by using FormHelper class in Cake PHP.
For Example:
Create file register.ctp in (/app/view/users) directory.
<?php
echo $this->Form->create('User', array('controller'=>'users', 'action'=>'login))
echo...
How to use md5() function in php ?
What is utilization of md5() function ?
MD5 stand to Message-Digest Algorithm, and MD5 is widely utilized in security-cognate applications.
It Calculates the MD5 hash of str utilizing the RSA Data Security, and returns that hash.
So, b...
HABTM in cakephp?
HABTM stands for Has And Belongs To Many.
Its is a cake php associations that we defined in a models for accesing associated data across different entities over the database tables.
Example - A product have more then one tags, and in the s...
CakePHP built-in sessions
CakePHP have several In-built sessions configurations. We can use these sessions as the basis or can create a fully custom solution for that. To use defaults inbuilt sessions, we can simply set the defaults
key to the name and can override any s...
redirect http to https in Zend Framework?
For redirecting http to https, please follow the below steps :-
First - Please Open .htaccess file from /public OR /public_html.
Second - Add below code in opened .htaccess at the top.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteR...