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 do I get a YouTube video thumbnail from the YouTube API?
Hello Readers!
We can use YouTube Data API to retrieve video thumbnails, caption, description, rating, statistics and more. API version 3 requires a key*. Obtain the key and create a videos: list request.
Example PHP Code
$data = file_ge...
How to remove duplicate values from a multi-dimensional array in PHP?
The array_unique() function removes duplicate values from an array. If two or more array values are the same, the first appearance will be kept and the other will be removed.
Example :
<?php
$a=array("a"=>"red","b"=>"green","c"=&...
How to use ucfirst() function in php ?
What is use of ucfirst() in php ?
The ucfirst() function is used for converting the first character of a string to uppercase.
Syntax of ucfirst() function:
ucfirst(string)
string is a parameter that is compulsory to given for convert...
What is superglobals Variables in php. ?
There are many predefined variables in PHP which are "superglobals", that denotes they are always accessible, regardless of scope.
and you can access them according to your need from any function.
So, there are 5 main superglobal variables i...
How to use of strtoupper() function in php.?
What is use of strtoupper() in php ?
The strtoupper() function is used for converting a string to uppercase.
Syntax of strtoupper() function:strtoupper(string)
string is a compulsory parameter
You can see below example of ucfirst() ...
How to use session in php. ?
Firstly let us know what is session ?
Session variables hold information about one single user, and provide to all pages information in one application.
So, session basicallu store informatiom in a variable and provine in multiple page for a ...
Redirection through htaccess file
.htaccess is the most useful file when we are working with php and apache. The directory level configuration of Apache server software is provided via .htaccess (Hypertext access) files. htaccess files defines mostly all the things like server se...
How to use of join() function in php.?
What is use of join() function.?
The join() function returns a string from the elements of an array.
The join() function alias of implode() function.
Syntax of strtolower() function:
join(" ",array)
You can see below example of join()...
URL rewriting with PHP using .htaccess
Hello Readers!
If you have this URL like : url.com/picture.php?id=51
and you want to make like this : picture.php/Some-text-goes-here/51 .
In this case it can be done by using htaccess.
Add a file called .htaccess in your root folder...
How to use of strtolower() function in php.?
What is use of strtolower() in php ?
The strtolower() function is used for converting a string to lowercase.
Syntax of strtolower() function:strtolower(string)
string is a compulsory parameter
You can see below example of ucfirst() f...
Send email using the GMail SMTP server from a PHP page
Hello Readers!
You people can use below code if you are using Gmail SMTP connection.
$from = '<fromaddres@gmail.com>';
$to = '<toaddress@yahoo.com>';
$subject = 'Hi!';
$body = "Hi, How are you?";
$headers = array(
'Fr...
What is use of ucwords() function in php.?
Definition of ucwords() function
This function is used for converting the first character of each word in a string to uppercase.
Syntax of ucwords() function:ucwords(string)
string is compulsory paramere
You can see below example of...
How to expire a PHP session after 30 minutes?
Setting the session creation time (or an expiry time) when it is registered, and then checking that on each page load could handle that.
Example:
$_SESSION['example'] = array('foo' => 'bar', 'registered' => time());
if ((time() - $...
How to parse and process HTML in PHP?
Hello Readers!
If you want to parse any HTML page then you would you "Simple HTML DOM Parser".
How to get HTML elements:
Create DOM from URL or file
$html = file_get_html('http://www.example.com/');
Find all images
foreach($ht...
How to fix Headers already sent error in PHP
Hello Readers!
You all got this error many times before and I am sure all PHP programmer at-least once got this error. To solve this error you can solve use solution as per your problem level:
Possible Solution 1:
You may have left blank...
How to use filter_var() function in php.?
What is use of filter_var() function. ?
The filter_var() function filters a variable with the specified filter.
Syntax of filter_var() functionfilter_var(var, filtername, options)
You can see below example of array_rand() function in php...
How to use array_rand() function php.?
What does array_rand() function in php.?
The array_rand() function returns a random key from an array, or it returns an array of random keys if you specify that the function should return more than one key.
Syntax of array_rand() function:a...
How to add Captcha with CakePHP
We can add captcha for blocking spams robots accessing our site or application. We can add captcha in our web application and website by using the below code ->
<?php
App::uses('AppController', 'Controller');
class PagesController exte...
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...
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...
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...
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...
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 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 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...
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 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 ...
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...
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 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...
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...
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...
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 ...
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...
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 ...
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...
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...