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
How the see the body of a submit post using PHP
POST is a common mode of sending or passing the values from one page to another, But on getting what exact is inside the post PHP will offer you the code syntax.
Consider the example below:-
We will get the body part froma POST request or c...
How to get first n Characters from a given string using PHP
Hello Readers!
On a given string if you want to take out the first n number of characters from it then PHP offers you 'substr' to get the characters.
Consider an example below:-
Suppose I want to get the first 5 characters from string, $MySt...
Diffrence between print_r and echo in PHP
Although the syntax echo and print in php is almost do same function. On the performance based work there are some difference between then:-
Echo is much faster in performance than Print, Since it will not return any value.
On the basis of...
How to detect mobile device in website using PHP
If you want to know any mobile device is accessing your website, Then the easy way to detect device is to run a php code.
Lets see the code below :-
<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
if(preg_match('/(android|bb\d+|meego)...
How to extract a number from given string using PHP
Using the PHP will give you several benefit to use code what you want.
And taking the number from any given string can be by diffrent - diffrent methods
lets se the example below:-
$myString = "I have 8 apples";
preg_match("|\d+|", $s, $myS...
How to make CSV File form array in PHP
Hello reader! If you have an array with the records and you want it to be download as CSV format. PHP has built in functions for making the format of CSV. Lets take the example below:-
header("Content-Type: text/csv");
header("Content-Disposi...
How to send SMS using PHP
Php offers you to make the integration of sms. We will discuss how to use php to send sms to any mobile number:-
Before we starts you need to have some any sms pack from mobile data companies but if you don't have you can make one you from twi...
How to compare two variable floats using PHP
While making the calculation with float variable one should really careful since there can be three cases, It can < or > or =. So lets see the example below and learn how to get the comparative.
$varOne = round(0.250, 3);
varTwo = roun...
How to use file_get_contents in PHP
Php offers you to send data in various ways like get, post. Using php you can also use file_get_contents
to send data using url. Lets see an example below:-
$information = array('http' => array(
'method' => 'POST',
'content' ...
How to make readable text from a pdf file in PHP
If you want to show a pdf file with the readable text from it on the page you can achieve it by seeing the code below
We will use a php library (pdfparser). This function will get the exact text as what you need
http://www.pdfparser.org/
...
How to make download a file strictly in PHP
On the execution of exe file you must need the property of header like Description, Type and Disposition
For making the strict/force download of a file in PHP you have to use the code below:-
<?php
$FileName = "http://abc.com/exa...
Best method for running all HTML pages act as PHP files
If you need something like all of your's html pages to be run like php files you can do the steps below:-
Step 1
Create a .htaccess file on your root.
Step 2
And add the line below
AddType application/x-httpd-php .html .htm
Or if...
How to make Email component in XAMPP
Hello Reader!
On using the PHP from your local host on XAMPP you can do several other things also
and we will learn how to configure mail from localhost using its sendmail package ,
The mail function is called sendmail, It's inbuild package ...
How to remove index.php from Codeigniter
Hello Reader! If you are new to working on Codeigniter Framework for PHP then you are very likely to encounter with the problem of index.php in url. Now we will see how to get resolve this error and then after you do not need to include index.php...
make your number to 2 decimal places round in PHP
Let's consider the example below using the function sprintf
$result = 3.146124;
echo sprintf("%.3f",$result);
output:
3.140
Alternatively, with printf:
$result_rounded = sprintf('%0.2f', $result);
Output
3.14
How to get the last key of an given array in PHP
Hello Reader!
Getting last the key index of any array PHP can be done on several ways as follows:-
Lets consider an example array $MyArray
$MyArray = array(
'one' => firstelement,
'two' => secondelement,
'three' =>...
How to get the file format/extension of file in PHP
Getting the file format or extension of any file can be done by various ways, In PHP you can use the one way as written bellow
$FileName = explode('.', $_FILES['photo']['name']);
$FileFormat = end($FileName);
Using the explode yo...
Combining two strings together in PHP
Combining of multiple using to add up one single can be achieve by various ways
In PHP you can either join then by using (.) Concatenate Operator or by using String Interpolation:
We'll do both of way here
Let's consider two stings
$o...
What are magic functions?
PHP have some magic methods that you can use in OOP (Object Oriented Programming). All the magic functions must be identified with twice underscores (__) prefix and they work as interceptors that will run when certain required conditions are met....
stdClass in PHP
"stdClass" is an void class of PHP. It can be as a act of the alternative of a associative array but works only on PHP 5 and more Any associative array.
You thought it of a object as same in java or python.
$info = array("question" => "sc...
How to get selected number of indexes/key from a array
If you need to get some limited key values of an array then you can use function array_slice used in PHP
Let see the example I'm having an array of 400+ values
$exp = array("34", "45", "45", "554", "2".......);
Now I'm limiting my thi...
How to remove blank spaces from Request using recursive in CakePHP
Removing the white spaces from a string is a easy task, but for doing this in whole of you website you need the recursive function in Cakephp
The 'array_walk_recursive()' will recursively get the request(GET/PUT) data and remove the white/blan...
What are the different errors in PHP
There are basically 4 different type of errors in Php.
Parse Error It stops the execution of php script . Commonly caused due to syntax mistakes in codes
E.g. Unclosed single double quotes, missing parentheses or adding extra parentheses...
General idea how ATM Machine Works
This blog will help the readers to understand that how ATM machine dispatches the money. Lets have a look on the ATM code in PHP:
<?php
$amount = $_REQUEST['amount'];
$rupees = array(1000,500,100,50,20,10);
$count = array(0,0,0,0,0);
...
How to correct error "Header already sent"
Hello readers. On developing the website the error 'Header already sent' is very likely to occur.
This is cause by PHP when it receives outputs like echo or html tags now it can take the data but then further passing it to HTTP will be very diff...
How to add watermark in image using PHP script.
Hi guys ,it really helps to add watermark on images . In this code you will see that we get the position of watermark .png image where you want to place then copy to the watermark image on the main images.
/*
* PHP GD
* adding watermark to a...
How to sort table columns using Table Sorter
Follow the given steps:
1) Add the script in your page
<script type="text/javascript" src="/path/to/jquery-latest.js"></script>
<script type="text/javascript" src="/path/to/jquery.tablesorter.js"></script>
2) I...
Play youtube video on web page and remove references of other youtube videos at the end of video
Hello Readers,
When we play a video on our webpage at the end of the of video it provides reference links of other videos so, if you want to play video and do not want to provide any reference links, below code will make this possible.
**H...
How to use caching in codeigniter
Web page caching
Lets we use the caching in codeigniter to achieve the maximum performance.
While CodeIgniter is quite fast, the amount of dynamic data you display in your hypertext pages will correlate directly to the server resources, memory...
How to get specific part of a URL
Hi Readers!
If you having a useful URL and want to extract the specific part from it you learn the logic below
Lets have a example
$yoururl = "http://www.abc.com/usefulinfo/";
Here I'm getting only the /usefulinfo/ word. For getting th...
Introduction to Cookies and Sessions in PHP
What is a Cookie?
A cookie can contain different data that is stored on the client browser with server specific information like user id and or user preferences.
What are Sessions?
Sessions are used to store information in the form of va...
FirePHP
Debugging means finding out the bugs.We all need to be sure that our applications is bug free, so here we have another tool for debugging our application that is "FIREPHP".
Firephp is a Firefox extension, similiar to FireBug. It enables you t...
Retrieve WordPress root directory path?
Wordpress provides different powerful functions which are useful for different prospective. We are going to discuss one function named get_home_path(). Through this function we can get the path of root directory in your wordpress setup. We can si...
Send an Email using email component in cakephp
Hello reader if you want to send email using the email component in cakephp you need to run the email component of cakephp
ex
You should place email send routine in your AppController:
function _sendMail($to,$subject,$template) {
$th...
How to get any File Name to PHP File using Command Line?
In Ubuntu system, first check for the PHP. For checking open the terminal, using command
**Ctrl +Alt +T**
and type whereis php
If PHP present in system, above command display the path of PHP
Make a PHP file from where you can acce...
File Handling in PHP - Tutorial 8
This blog explains about various functions used for File Handling in PHP.
Date and Time in PHP - Tutorial 7
This blog explains different functions used for date and time manipulation in PHP.
Debugging techniques for PHP programmers
Error messages area unit your 1st line of defense as a developer. you do not need to be developing code in PHP on a server that's not organized to show error messages.
However, confine mind that once your code is debugged and prepared to travel ...
eliminate php5 Strict standards errors
Hello readers!
If you have recently upgraded you PHP from PHP 5.3 to PHP 5.4 . Then it might be possible that your script is displaying a lot of error messages. If you want to hide these error you just need to change in your cakephp setup
Th...
Integrating Twitter with Magento
Social media... Now a days social media is a part of life or requirement of time. We are here to discuss integration of twitter with magento. We all have twitter account. Am I right?. We can integrate twitter to magento with different ways. Like ...
Creating Non Default Themes in Magento
Welcome to this blog.
Today we are going to discuss non-default themes in magento. We all knows magento is a powerful eCommerce platform where you can easily build your stores. If you want to work on magento then you need to understand it's fil...
How to Use AJAX in a WordPress Shortcode?
We are going to process ajax request in wordpress shortcode on button click. First of all you need to add the shortcode in wordpress. Kindly write below code in function.php
<?php
function callback_listing($atts, $content = null)
{
e...
OAuth 2.0 Authentication on Wordpress site
We are here to discuss OAuth 2.0 Authentication in wordpress. Do you know about OAuth?. What is OAuth?. OAuth is nothing but a open protocol which is useful to allow authorization by easy and secure methods from web/mobile/software applications.
...
Rename files during upload within Wordpress backend
If you want to rename the file name at the time of upload, it is a right place to know the solution. Let's discuss this requirement.
We all know there are many hooks available in Wordpress. We will use the filter named sanitize_file_name. You ...
Wordpress: How to call a plugin function with an ajax call
In web development field we face different situations in order to fulfil the requirements. Sometimes we have to customize the well managed CMS/frameworks. Today we are going to take an sample example of wordpress plugin development. There is one ...
Page Processing in PHP
PHP has three types of modules which are as following.
A) Core PHP : This modules handles requests, error handling as well as file streams.
B) Zend Engine: It convert the php code into machine tokens or opcode and it will execute it in a vi...
How to make custom error pages in CakePHP 2.0
Hello reader!
If you want to set a custom error webpage for your whole cakePHP project you can set this page at
/views/layouts/default.ctp as layout for these error pages like 404/ page not found
To customize it and set your own message, o...
How to use Bootstrap pagination with CakePHP pagination helper
Hello, if you are using pagination with cakephp framework and want to change the view of pagination just like twitter bootsrap then you can do this by doing follow changes in you view and css.
We can do it by writing some custom classes in view ...
Find where field is not null in cakephp
Hello Readers!
if you have a database table "users" which has a field "email". And you are looking for a query that fetch out every email field only which are not null in cakephp
Here is the following code below you can use, and its working ...
How to get Latitude/longitude from address in PHP
Hello All,
In this blog we will discuss about how to fetch the lat/long from the given address in PHP.
So we will be using curl request for fetching the same via using Google maps api.
Below is the code, you can use to generate lat/long...