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 to redirect 404 error page to custom 404 page
When a visitor visits any wrong URL in the site , they see 404 not found error comes from server side by default. We can redirect the visitor from any invalid URL to any of the custom page or any page we want. For the most of the sites , we see t...
How to pass arguments to PHP
Hello Reader's If you have some arguments that you want to pass into function and elements of that array you pass will then be received by your function as distinct parameters.
For instance, if you have this function :
function test() {
...
How to make conversion of base64 to image using PHP
Hello Reader's If you have some string in base64 and you need them to convert into image file, Then by using PHP you can do this as follows:-
function base64Tojpeg($base64_string, $output_file) {
$ifp = fopen($output_file, "wb");
$dat...
How upload only max 4 images in PHP?
Hello Reader's if you are developing the website and you want to restrict file upload to max of 4 then you can use the code as below:-
The logic for this condition is you just have to return false is count of array is more than 4. Let's see ho...
What is proccess to get the file extension in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss What is process to get file extension in PHP ?
There are many ways for getting the file format or extension of any file.
In bellow example you can see how to get the file forma...
What is diffrence between echo and print in PHP ?
Hello all,
Welcome to FindNerd, today we are going to discuss the difference between echo and print statement in PHP ?
echo and print both are used to printing a statement.
So here are few important point given below to differentiate bet...
How to restrict the file type to be upload using PHP
Hello Reader's If you are uploading the attachments with only selected file types then you have to use inarray function.
Let's see the example as below:-
Put the allowed types in an array and use in_array().
$file_type = $_FILES['foreign_...
How to list the visitor to your website using PHP
Hello Reader's if you want to know the users which are accessing your website then you can get them by their IP. Lets see the example as below:-
Try this simple PHP function.
<?php
function ip_info($ip = NULL, $purpose = "location", $...
How to make PHP page as an image in return
Hello Reader's If you have to return a image from PHP page. then you can use the code as written below:-
<?php
// open the file in a binary mode
$name = './img/ok.png';
$fp = fopen($name, 'rb');
// send the right headers
header("Cont...
How to create coma separated string from an array
Hello Reader's if you have an array and you want it to converted into string with separated by coma then by using PHP you can do this as follow:-
You have to use Implode function
$arr = array(1,2,3,4,5,6,7,8,9);
$string = rtrim(implode(...
How to get the name and details of function being called by PHP
Hello Reader's! if you want to get the name of function and method being called, Then by using PHP you can do this as explain below:-
Lets's see the example as below:-
We use the info provided by a php exception, it's an elegant solution:
fu...
How to send email using Wamp server in PHP
Hello Reader's If you are working on your local host and not able to send the email then by configuring your WAMP server you can send email.
Let's see how it is done:-
First just install Fake Sendmail (download sendmail.zip). Then configure ...
How to select images from database and show on page
Hello Reader's! If you have stored the image in database as blob. Then you need a php code to retrieve them and a html page to show them. Lets see an example below how to show them
First create a php page getImage.php and code as written below...
What to you mean by variable $this mean in PHP?
Hello Reader's!
If you have any doubt with the $this in PHP then you can see the example as below:-
<?php
class Person {
public $name;
function __construct( $name ) {
$this->name = $name;
}
};
$t...
How to remove extra white spaces from string using PHP
Hello Reader's! if you are dealing with excess whitespace on the beginning or end of the string then you can use trim(), ltrim() or rtrim() to remove them. Also If have to delete extra spaces within a string consider a preg_replace() of multiple ...
How to dynamic generate password in PHP
Hello Reader's If you want to genrate password in PHP then you can use the code as below:-
you just have to try this, use strlen instead of count, because count on a string is always 1:-
function randomPassword() {
$alphabet = 'abcdefg...
How to unlink a directory by using PHP
Hello Reader's If you want to delete a folder and all the files in it then by using PHP recursive function you can do it.
Let's see on example as follows:-
Before deleting the folder, delete all it's files and folders (and this means recurs...
How to get dates between two given dates in PHP
Hello Readers's if you want to get a recursive set of dates between two given dates, For example
10-12-2105 to 19-12-2015 there are 9 days all will have different dates. By using PHP you can get this as using the code below:-
$startTime = st...
Difference between include and require in php
Hello Reader's If you are new to php then you must have to understand the difference between include and require, Lets see some of major difference between them.
Using require means your script will halt if it can't load the specified file, an...
How to adjust height of animated GIF file using PHP
First of all you just have to create 3 folder name
1.frame_output
2.images
3.resized_frame_output
Now download encoder and decoder class from this below link
here.
And Download class "GIFDecoder.class.php", Download class "GIFEncoder...
How to convert Image into base64 encoding using PHP
Hello Reader's!
If you want to to encode an image with base64 then by using PHP you can do such. You can use the code as below:-
This method is very simple and commonly used:
function getDataURI($imagePath) {
$finfo = new finfo(FILEI...
How to delete characters which can not be printable
Hello Reader's if your page is generating some non readable characters that are not able to print then by using PHP you can remove them as follows:-
Many of the other answers here do not take into account unicode characters (e.g. ). In this c...
How you can set multiple checkbox in an array using PHP
Hello Reader's if you want to send the checkbox in post for this you have to pass the form name as an array and afterwards you can access all checked boxes using the var itself which would then be an array.
Lets consider the example below:-
&...
How to fix HTTP header to UTF-8 using PHP
Hello Reader's If you want to set the HTTP header to UTF-8 then html will itself allows you to convert it. But if you want it to be wrap by using PHP then you can use the code below:-
You just have to use header to modify the HTTP header:
...
How to get the text matter from a given PDF using PHP
Hello Reader's, If you want to write a program that takes the matter from a given PDF then now you can use many libraries. These are well function performing and easy to use.
Lets see an example below:-
Download the class.pdf2text.php from he...
How to get all folders in a given folder using PHP
Hello Reader's! If you want to get all of the folder inside a given directory then PHP offers you many ways to do that, Lets see them from the basic programs.
you can use glob() with GLOB_ONLYDIR option
here's how you can see how to retrieve...
Difference between PHP $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME']
Hello Reader's!
In working PHP you might have seen the two common syntax $_SERVER['HTTP_HOST'] and $_SERVER['SERVER_NAME']. They share similar name but they work different.
$_SERVER['SERVER_NAME'] gives the value of the server name as defin...
How to the use file_get_contents() in PHP ?
Welcome to findnerd, today we are going to discuss How the use file_get_contents() in PHP ?
Fistly let know what is use of file_get_contents() ?
The file_get_contents() basically reads a file into a string.
So we can say that file_get_con...
What is procees to print HTML page with tags using PHP ?
Hello all welcome to findnerd, today we are going to discuss How to print HTML page with tags using PHP ?
The htmlspecialchars() Function is very useful print HTML page with tags using PHP
Firstly let know what does htmlspecialchars() Func...
How to convert given digits to words using PHP
Hello Reader's! If you have given digits of number and you want it to convert into words for example 76 will be converted as seventy six and 102 will be convert as one hundred two
Lets see the function below:-
<?php
function digitti...
How to get file information using PHP
Hello Reader's If you want to get the full path , name or the directory of a file using php then you can use the code below:-
Let's see the example below:-
function filePathParts($arg1) {
echo $arg1['dirname'], "\n";
echo $arg1['bas...
How to validate url in php
Hello Reader's! If you have a url given and you want to check weather it is valid or not. For example www.facebook.com is a valid but www.fcebook.com is invalid link.
By using you can do this by Curl function, Lets see the example below:-
f...
How to integrate PHP Mailer
Hello Reader's!
If you want to send email some other than php mail then php mailer is the best option. PHPMailer provides an object oriented interface, but in case of php mail() is not object oriented. Let's see how to integarte php mailer funct...
How to maximise the maximum size of POST in PHP ?
Welcome to findnerd, today we are going to discuss How to increase maximum size of POST in PHP ?
If you want to increase the size of POST for sending much more POST request, then you have to follow bellow given point.
There are 2 different ...
How to pass JavaScript variables to PHP
Many a times we got stuck in a case or situation where we have to pass JavaScript variables to PHP using a hidden input in a form. The solution for this situation is:
Solution:We cannot pass variable values from the current page javascript...
Convert one date format into another in PHP
Date play an important role in any project. We have to change date format according to our need. If we are using PHP 5.2 and lower then for changing date format we have to parse the elements (year, month, day, hour, minute, second) manually using...
Login with linkedin in php
Follow the below steps in order to use the linkedin API.
Go to the Apps page at LinkedIn
Developer Network and login with
your LinkedIn account credentials
https://www.linkedin.com/secure/developer
Click on the Add New Application
link...
How to Create and Use Cookies in PHP
Cookies are basically small text files that is stored in browser and it is use for tracking purpose.
Cookies are also use for remember me functionalities.
Setting Cookies with PHP
setcookie(name, value, expire, path, domain, security);
...
How to redirect user with session message in Codeigniter?
Hello Reader's If you want to make user redirect and show him the error message on next page then by using codeigniter you can do by following functions:-
Let's say if user input wrong username/password then you'll redirect user by following c...
How to send mail using Codeigniter mail function in php
Hello Reader's! If you are working on PHP framework, Codeigniter then you should learn how to send mail by its functions.
CI offers you the best way to configure the email and send the mail and you just have to call it on the place required.
...
How to send attachments in mail using PHP
Hello Reader's! If your mail is contating some attachments then you can use the simplest way to sending the mail with attachments.
Lets see the example below:-
$email = new PHPMailer();
$email->From = 'you@example.com';
$email->...
How to send mail with multiple CC using PHP
Hello Reader's! If you want to send the mail to multiple CC or BCC then you just have to put the emails separated by coma. Lets see the example below:-
First create and string with coma separated cc emails:-
$cc = 'abc@gmail.com,zye@yahoo.com...
Static Method in PHP
When you declare class method as static then these method can be called without instantiating of the class .
When you declare a method or a variable static then we must use static keyword before declare this and when accessing these method or ...
Check username availability on keypress using jquery
Username or email availability or any other types of availability check we can do in this way. When user type on a text box an ajax request has made and check what if its available or not. we only required jquery.js
HTML
<input type='te...
How to fetch twitter user feeds using PHP
If you want to display twitter user feeds then use the below code of flow.
First of all for user timeline json you have to visit below twitter link.
http://dev.twitter.com/doc/get/statuses/user_timeline
For detail parameter please visit....
Extract Zip File Using PHP
If we do not have access to shell and we want to extract a zip file then just put the below php piece of code and run.
$zipObj = new ZipArchive;
$file = $zipObj->open(zip_file_name.zip);
if ($file == TRUE) {
$zipObj->extractTo('ex...
Cakephp ajax pagination using jquery
Using default pagination helper in cakephp.
<div class="paginator">
<?php echo $paginator->first(' First ', null, null, array('class' => 'disabled')); ?>
<?php echo $paginator->prev('Previous ', null,...
Upload File using Aajx
Sometime you need to upload the image without refreshing the page , in that case you can upload the image with the help of ajx using FormData Objects .
To achieve this lets create a form in HTML to upload the file.
<div class="control...
How to fetch data from database in php ?
Welcome to findnerd, today we are going to discuss fetch data from database in php .
In this blog you can fetch data from database .
Firstly establish a database connection
Use the mysqli( ) function to established connection to the MySQ...
Remove duplicate Array from Multidimensional Array with the key defined
Here we will learn that how we can remove duplicate Array from multidimensional Array according to the key in the Array.
Lets look at the example below :-
Here I have initialized one multidimensional Array, now I would like to remove thos...