Featured
-
How Regression Testing Detects Integral Errors In Business Processes
Humans are forever changing and evolving and so to
by kristina.rigina -
Get Display Banner Advertising Opportunity on FindNerd Platform
“Do you have a product or service that nee
by manoj.rawat -
Android O Released with Top 7 New Features for App Developers
Android was founded by Andy Rubin, Rich Miner, Nic
by sudhanshu.tripathi -
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 -
Objective C or Swift - Which Technology to Learn for iOS Development?
Swift programming language is completely based on
by siddharth.sindhi
Tags
How to get current unix timestamp in PHP
Hello Reader's if you want to get the current time stamp of Unix in PHP, Then PHP offers your to use this by getTimestamp().
Now let's see this in the example below:-
<?php
$date = new DateTime();
echo $date->getTimestamp();
?>
...
How to find elements from the group array in PHP
Hello Reader's! if you have set of arrays and you want to get all of them seperatly then the code below will help you.
Let's say if you have
[ [a], [b], [c], [a, b], [a, c], [b, c], [a, b, c] ]
and you want this
[a,b,c]
The c...
File upload in PHP.
Hello Reader's ,
While building any appication we definatley requires images to upload like profile image , company image etc , for this we require php file upload code .
You will get image data in array i.e. image name , temp name , image...
How to crop images in PHP
Hello Reader's if you want to crop the images and save them then you can use this code liberay, its a very easy to implement and very useful for thumbnail generation
<?php
$targ_w = $targ_h = 150;
$jpeg_quality = 90;
$src = 'demo_files...
Less than equal to query in codeigniter
Hello reader's If you are using codeigniter and want to make '<=' mysql query then you can use the code syntax as below:-
->select('COUNT(payment.keyid) AS rec_count')
->where('payment.paymentdate >=', $month_start)
->where...
What is the use of the @ symbol in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss what is the use of the @ symbol in PHP ?
so basically @ symbol is an "Error Control Operators" and it's works only on expressions.
In other word we can say that this symbo...
How to extract a number from a string in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to extract a number from a string in PHP ?
If you just want to filter the numbers out, the easiest is to use preg_replace() function.
It is very simple and easy function ...
How to use json_encode() function in php ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to use json_encode() function in php ?
So, Firstly let us know what is the use of json_encode() function ?
JSON stands for JavaScript Object Notation. json_encode() is ...
What is the use of fgets() in PHP ?
Hi Reader's,
Welcome to FindNerd, today we are going to discuss what is the use of fgets in PHP ?
Firstly let us know what is fgets()
The fgets() function is used to return a line from an open file.
syntax of fgets()
fgets(file...
How to set different menu for different page in wordpress
We can set different menu links for every page in wordpress. Sometimes we get the requirements from the client to have different menu links for every pages. It can be done, Its quite coding part. For each pages we have to set different menus from...
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 pass a variable in jQuery from PHP
Hello Reader's! If you want to send variables from PHP to jQuery then you have to use the selectors:-
Lets's see the example below:-
This you have to put in the bottom of php page with the selector is "input[type=checkbox]"
$("input[typ...
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...