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
Including files in PHP
In PHP there is a feature which allows to write code in a different file and call it where ever there is a need for executing the code. this can be done by using the include and require functions.
with the help of the these two functions we ca...
PHP $_SERVER superglobal variables.
$_SERVER is a PHP super global variable which holds information about headers, paths, and script locations.
The example below shows how to use some of the elements in $_SERVER.
<?php
echo $_SERVER['PHP_SELF'];
echo "<br>";
echo ...
Why to use CakePHP ?
Code generation: CakePHP Framework generates the code automatically using the bake command which enable the developer to execute the bake command.
Database: programmer is not required to write Insert, update, select & delete queries becaus...
Facebook SDK for PHP
Hello Readers ,
The following code demonstrate how you would accomplish common tasks with the Facebook SDK for PHP.
This SDK can be use in facebook login , Retrieve a user's profile , Post a link to a user's feed.
window.fbAsyncInit =...
How to use str_replace () function in php ?
What is utilization of str_replace () function ?
there are 3 main uses of str_replace () function in php.
1-str_replace() function supersedes some characters with some other characters in a string.
2-str_replace() Supersede all occurren...
How to use strpos() function in php ?
What is the strpos() function ?
The strpos() function searches for a concrete text within a string.
In other word we can say that strpos() function use for searching position of Text Within a String.
If text word match will found, th...
Foreach in reverse order
We can use array_reverse function to invert the values of array.This way we can allow them to get reverse order.
Ex : -
$data = Array(
'ProductA',
'ProductB',
'ProductC',
'ProductD',
'ProductE'
);
foreach ( array_reverse(...
Exceptions in CakePHP
CakePHP uses the exceptions internally to show the logical cake PHP errors. All of the exceptions that occur in CakePHP raises a CakeException.
CakePHP is also having the number of exception classes that we can use for HTTP errors.
For con...
Html Helper in CakePHP
If you want to make your page more reliable ,then Use HtmlHelper instead of html tag in your (xyz.ctp). CakePHP Helper will enable your application more light & flexible. By using these HtmlHelper ,we can create well formed markup in our Cake...
How to use user defined function in PHP ?
Firstly let us know What is the user defined function in php ?
This function declaration starts with the word "function" and user defined function name is not case-sensitive.
User defined function starts with a letter not a number.
Use...
How to use arsort() function in php ?
What is tht arsort() function in php ?
The arsort() function sorts an associative array in descending order, as reported by the value.
why use arsort() function in php ?
arsort() is fundamentally used when sorting associative array in ...
Ways to get data from one page to another page in PHP?
Hello Readers
In php there are many different ways to get the data from one page to another page in php.
Using session by passing values between pages: This is the one of the method to get the data from one page to another page in php and...
How to use asort() function in php ?
What is tht asort() function in php ?
The asort() function sorts an associative array in ascending order as reported by the value.
why use asort() function in php ?
asort() is fundamentally used when sorting associative array where the...
Functions in php
A function is a group of statements that does a special task. the function can be called repeatedly to execute the same statements.
The syntax of the user defined functions in php is as :
function functionName() {
code to be executed;
...
How to use implode() function in php ?
What is tht implode() function in php ?
The implode() function basically utilized to join elements of an array with a string. So in other word we can say, it takes an array and returns a string.
syntax of implode() function
implode (sep...
How to use rsort() function in php ?
Let us know What is tht rsort() function in php ?
The rsort() function sorts array in decending order menas highest to lowest.
why use rsort() function in php ?
rsort() function basically used for sorting the elements of the array in d...
How to create Cookies With PHP
Why we create cookies ?
cookie is used to identify any user. A cookie is known as a very small file that the server copy into the user's computer browser. Whenever users request a web page using the same computer , it will send the cookie too....
How to use sort() function in php ?
What is tht sort() function in php ?
The sort() function sorts an indexed array in ascending order means lowest to highest .
why use sort() function in php ?
Sort() function basically use for sort the elements of the array in ascending...
How to use explode() function in php ?
Firstly let us know why we use explode() function in php ?
explode() function basically used for breaking a string into an array in php.
explode() function is binary-safe in php.
explode() function syntex is given bellow:
explode(','...
foreach loop in php
In php foreach loops are used to access all the elements of the array. The syntax is as
foreach ($array as $key =>$value)
{
}
In above syntax , the no. of times loop get executed is equal to the no of elements in the array.
the...
Two dimensional Array sorting
Here we will learn how we can sort two dimensional array:-
lets take an example :-
<?php
$activities = array (
'1' => array(
'id' => 1,
'time' => "2015-10-22 14:20:00"
),
'2' => array(
...
How to change the image in template in Joomla
You can change the image of your template by following ways:
Change the image reference of your choice in the HTML file of the template.
The images in Joomla for a template are generally placed in this folder:
/templates/templatename...
How to Customize YouTube Embed Player ?
Hello Readers
The below post show the customization of youtube embed player by using some youtube defined parameters.
Now a days most of the developer use the embed iframe tag for displaying the videos because this improves the projects pla...
How to utilize array_values() Function in php ?
why we use array_values() function in php ?
The array_values() function use for returns an array which have all the values of an array.
you can see below example:
<?php
//firstly create a array of a city detail
$Citydetail=array(...
How to take backup of a table in MySQL using PHP?
You can use PHP to take backup of a table in MySQL. For this, you need to write the following code:
$dbhost = 'localhost';
$dbuser = 'dbusername';
$dbpass = 'dbpassword';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
...
include and require statement in php
In php you can include the content of one PHP file into another PHP file using the following statement:
include statement:
It will produce a warning if the file is missing or uable to load the file and the script continues to execute.
Syn...
How to use time() Function in php ?
What is use of time() Function in php ?
Php time() function basically use for returns a current unix timestamp. In which, you can utilize the date() function to format it to your desiderata.
You can see below example of time() function...
How to use addslashes() functionin php ?
What is addslashes() function ?
The addslashes() function basically used to returns a string with backslashes before characters that need to be quoted in database queries.
Mostly it is used for predefined characters, addslashes() function i...
How to add custom field in wordpress for category
Hello Reader's! if you are new to wordpress development and need to add more custom fields in category, Then you can learn it from the code below:-
Step:1-
Open the file functinon.php and add the following code in it.
add_action( 'category...
Difference between Static and Dynamic site?
Hello Readers
The below is the difference between the static website and the dynamic website:
Static website is a site which is used using HTML. In this each web pages is a static type means separate document there is no use of databases ...
Superglobal Variables in PHP
Superglobals variables in php are the built-in array. They are available in every scope. You can access the superglobal variable inside and outside the methods.
PHP Superglobals variables:
$_COOKIE
contains values provided to the scri...
How to use wordwrap() Function in php ?
What is wordwrap() Function in php ?
wordwrap() Function wrap a string into incipient lines when it reaches a concrete length.
So,basicaly use of wordwrap() wraps a string into new lines. wordwrap() include space also.
You can take re...
How To Install Plugins in Cake PHP
There are four ways to install a plugin in CakePHP->
Plugin install through Composer
Manually plugin install
Plugin installed As Git Submodule
By Git Cloning
1- Manually
To install a plugin manually in CakePHP, you just have to m...
How to set - unset layout in CakePHP ?
How to set/unset layout in CakePHP ?
CakePHP provides by default layout in (app/View/Layouts/default.ctp) file, so we need different layouts for different pages as per our requirement.
Change the default layout in all web pages
var $layo...
How to use trim() Function in php ?
Why we use trim() Function in php ?
The trim() function mainly use for removes the spaces from the beginning and the end of the string.
trim() function will divest and control characters such as :
" " an ordinary space.
"\t" a t...
How to update a field in the database in cakephp 2.x
To update a a field in the database in cakephp we uses an array,
the task is done as,
$this->request->id = $id;
$data=array();
$data['User']['id'] = $this->request->id;
$data['User']['fname'] = $filename;
$this...
How to upload a file in cakephp 2.x
Uploading a file in your application can be used to upload an image or documents.
With the help of the cakephp html we can create a form with the input field of type file which allows to browse and select the file from your systems.
lets cr...
How to use of "ksort" in php
Firstly we will know what is the use of "ksort" in php
"ksort" is used to sort the array by key and this is useful for associative arrays.
You can see below example for "ksort".
<?php
//suppose we want sort employee age from ...
New term for PHP, Composer
Composer is nothing but a tool which is useful for dependencies management. Composer supports only 5.3.2+ version of PHP. Now a days most of the frameworks are using PHP composer. This idea comes from node's npm and bundler from ruby. You should ...
Enable https on localhost
enable https in localhost
For OS Ubuntu
sudo a2enmod ssl
service apache2 restart
-- If this doesn't work try this
sudo a2ensite default-ssl
service apache2 reload
Now hit your localhost
https/localhost
How to utilize use of count() function in php
what is count() function
The count() is utilize to count all data elements in an array, or in other word we can say The count() function returns the number of elements in an array.
You can see below example of count() function.
...
Using CSS in Laravel views.
CSS plays an important role in every project. In Laravel 4.x we will define our css in:
public/css/custom.css
Here In above path we will define our css in laravel 4.x
To call a view from controller we will use the code as follow:
Ex...
Ubuntu enable mod rewrite in apache server
Go to this directory.
etc/apache2/apache2.conf
you will find below code with AllowOverride none.
<Directory />
Options FollowSymLinks
AllowOverride none
Require all denied
</Directory>
<Directory /usr/sh...
.htaccess in Cakephp
Without .htaccess file in cakephp your application will not run.
There are 3 different .htaccess files:
/var/www/app/webroot/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d...
Group By in Cakephp
The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.
Below is the possible keys that we use in cakephp query.
$params =
array(
'conditions' => array...
Laravel 4: how to order by using Eloquent ORM
In Laravel 4.x we have many facility to use query in a easy way. We will also run raw query in laravel 4.x. Laravel 4.x also provide of using order by query using Eloquent ORM.
We can easily understand this by seeing the example of order by...
How to make custom error pages in cakephp
Hello Readers ,
If any one enters the wrong URL then how to show our custom error page , follow the below code.
Exception render need to set as an AppExceptionRender.
/app/Config/core.php
Configure::write('Exception', array(
...
How to define host and port using Laravel 4.x
Now a days there are n number of website which will move to android. So for every application we have to make API. If we will make our API in laravel 4.x then we will test using Postman. To define our port and to run our API using "Postman" we ha...
How to use array_search() Function in php
what is array search ?
Array search returns the corresponding key if search is successful and Searches the array for a given value.
You can take reference form below example.
<?php
//firstly create a array
$employeName=array("1"...
How to create SSH connection with Filezila
If you are looking to create secure ssh connection in filezila with .ppk file. Please follow the below instruction:
1) Open your filezila.
2) On the top menu bar please click at Edit --> Setting
3) Now a pop up will appear. On the right s...