web stats analysis

PHP Archive

How to get Indian Rupee Symbol in C#.Net?

How to use XML?

What is XML?

XML stands for eXtensible Markup Language.
XML is designed to transport and store data.
XML is important to know, and very easy to learn.

Below, there is an example of xml for your better understanding.


<?xml version="1.0"?>
<note>
<to>Bhavesh</to>
<from>Prakash</from>
<heading>Little information</heading>
<body>Give respect take respect(code.top10idea)</body>
</note>

How to pass a Javascript Array via JQuery Post so that all its contents are accessible via the PHP $_POST array?

How to send an array via the url in javascript/jQuery?

If you want to pass a JavaScript object/hash (ie. an associative array in PHP) then you would do:

$.post(‘/url/to/page’, {‘key1′: ‘value’, ‘key2′: ‘value’});

If you wanna pass an actual array (ie. an indexed array in PHP) then you can do:

$.post(‘/url/to/page’, {‘someKeyName’: ['value','value']});

If you want to pass a JavaScript array then you can do:

$.post(‘/url/to/page’, {‘someKeyName’: variableName});

what is the syntex of basic php?

Syntex of basic php.

Basic php syntex is below:


<?php

// Write PHP code  here.

?>

Little demo of php:


<!DOCTYPE html>
<html>
<body>

<h1>My demo PHP page</h1>

<?php
echo "Hello pcube members!";
?>

</body>
</html>

How to use for loop in php wordpress?

Use for loop in php wordpress.

Following demo to use php in wordpress.


<?php
for ($i = 0; $i < 10; $i++)
{
echo '<div class="pin">

<a href="#" title="Photo number 1" pin_id="1">
<img alt="Photo number 1" src="photos/pic1.jpg">
</a>

</div>';
echo '<div class="pin">

<a href="#" title="Photo number 4">
<img alt="Photo number 4" src="photos/pic4.jpg">
</a>

</div>';
}
?>

How to create cookie in php?

How to create Cookie in php?

What is the use of Cookie in php?

How to use Cookie in php?

Description about Cookie is bellow:

Cookie is a small file.Cookie is used to identify a user.
At a same time computer send requests a page with a browser, it will send the cookie too. With php,
you can both create and retrieve cookie values.

How to create Cookie?

The setcookie() function is used to set a cookie.
Note:The setcookie() function must appear BEFORE the <html> tag.

Syntex of Setcookie.


setcookie(name, value, expire, path, domain);

Bellow example:

I will create a cookie named “Name” and assign the value “Peter” to it.
I also specify that the cookie should expire after one hour:


<?php
setcookie("Name", "Peter", time()+3600);
?>
<html>
.....

Bellow example2:

We can also set the expiration time in cookie in Other way.


<?php
$expire=time()+60*60*24*30;
setcookie("Name", "Peter", $expire);
?>
<html>
.....

Above example expiration time is set to a month (60 sec * 60 min * 24 hours * 30 days).

How to Retrieve a Cookie Value?

The PHP $_COOKIE variable is used to retrieve a cookie value. :
below example,we retrieve the value of the cookie named “name” and display it:

<?php
// Print a cookie
echo $_COOKIE["Name"];

// A way to view all cookies
print_r($_COOKIE);
?>

following example we use the isset() function to find if a cookie has been set:


<html>
<body>

<?php
if (isset($_COOKIE["Name"]))
echo "Welcome " . $_COOKIE["Name"] . "!<br>";
else
echo "Hello Friend!<br>";
?>

</body>
</html>

How to Delete cookie?

If you want to delete cookie you should assure that the expiration date is in the past.


<?php
// set the expiration date to one hour ago
setcookie("Name", "", time()-3600);
?>

What is session variable in php?

How to create session in php?

What is the use of session?

How to use session in php?

Description about session is bellow:

A PHP session is also One type of variable..
Which is used to store information.
Session variables Store the information about single user, And In the one Application all pages are available.

PHP session variable

Always we working with any application,
We just open it,do something work and closed it.
computer knows evrything what you do.
But server has a oine problem.
It’s don’t know actually what yoiu do? It’s doesn’t metter.
That’s why server need session.

sessions work by creating a unique id for each visitor and store variables based on this uniqe id.
The UID is stored in a cookie or either is propagated in the URL..

How to start php session?

Note: The session_start() function must appear before the tag:


<?php session_start(); ?>

<html>
<body>

</body>
</html>

How to store session variable?



<?php
session_start();
// store session data
$_SESSION['views']=1;
?>

<html>
<body>

<?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];
?>

</body>

Below example, we create a simple page-views counter.
The isset() function checks if the “views” variable has already been set.

<?php session_start(); if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+1; else $_SESSION['views']=1; echo "Views=". $_SESSION['views']; ?>

How to Destroying a Session?

When you want to delete some session data, you can use the unset() or the session_destroy() function.

The unset() function is used to free the specified session variable:



<?php
session_start();
if(isset($_SESSION['views']))
unset($_SESSION['views']);
?>

If you want to completly destroy the session So, you can
By calling session_destroy() function:



<?php
session_destroy();
?>

What is variable scope in php?

Scop of variable
Php already has a Variable Scops..Which like Below
Here, Four type variable scops available.
Global.
Loval.
Static.
Parameter.
Global Scope.
Little Discription about Global
Global variable is decaler outside of any functionWe can acceess Global variables in anywere.When you want to access a Global variable, use the “global” keyword:
Example.
<?php$a=10;

$b=20;

function demo()

{

$GLOBALS['b']=$GLOBALS['a']+$GLOBALS['b'];

}

demo();

echo $b;

?>

We can create an array of all global variable in PHP,Using $GLOBALS[index]

Here..

=>index contain variable name.

We can update global variable.

Example
<?php$a=5;

$b=10;

function demo()

{

$GLOBALS['b']=$GLOBALS['a']+$GLOBALS['b'];

}

demo();

echo $b;

?>

Local Scope.
The variable declare inside the function is call local variable..
Example
<?php$a=10; // global scope

function demo()

{

echo $x; // local scope

}

demo();

?>

Static Scope.
Every time the variable is remuve after completed function.But,many time you need local variable not remove.

This time use Static variable.

Example.

<?php

function demo()

{

static $a=0;

echo $a;

$a++;

}

demo();

demo();

demo();

?>

Parameter Scope.
A parameter is a local variable.

Parameters are define in a parameter list it’s kind of the function:

Example
<?phpfunction demo($a)

{

echo $a;

}

demo(10);

?>

Scope variable in php,What is Scope variable in php,local variable,global variable,static variable,parameter variable,

What is variable scope in php?,learn variable scope in php.

What is meaning of $_GET in PHP?

The $_GET Variable

$_GET is a predefine Variable of php.

$_GET Variable is use to get the value into a form with method=”get”.

pass imformation from a form with the get method is visible.

And we can pass only limited information in get method.

Pass information is visible So,it is not secure..

Like This..

http://www.code.top10idea.com/home.php?fname=Peter&age=37
what is $_GET,$_GET,$_GET variable,$_GET variable in php,learn $_GET variavle

What is the meaning of $_POST variable in PHP?

The $_POST Variable

$_POST is a predefine Variable of php.

$_POST Variable is use to get the value into a form with
method=”post”.

pass imformation from a form with the post methodand information is visible.

And we can pass Unlimited information using post method.

Pass information is unvisible So,it is very secure.

Like This..

http://www.code.top10idea.com/home.php

what is $_POST,$_POST,$_POST variable.$_POST variable in php.