Categories
php

PHP: Passing Variables from One Page to Another

There are two methods by which one can pass variables from one page to another. One is GET method and the other is POST method.
In GET method we pass the variables and their value in the url like

[php]

http://urtl.com/video.php?var1=xxx&var2=xxx2

[/php]

etc and you fetch the variables using $_GET

[php]

$title = $_GET[“var1”];
$title2 = $_GET[“var2”];

[/php]

Post method is used in form. When form is submitted the values are passed from the text fields to the destination page. We retrieve the values as

[php]

$title = $_POST[“varl1”];

[/php]

where var1 is the name or id of the form text element or the element of the form which contains specific data we are requesting.

Categories
functions php

PHP: Renaming File

To rename a file in php use
rename();

you use the function like

rename(“oldname”, “newname”);

you have to include the path to file if it is present in sub directories where your php script is present.

Categories
functions php

PHP: Function ucwords

This function ucwords capitalizes first alphabet of every word in a String and returns it. This is useful for converting or renaming files or directories..

usage:
$string = “name sake”;
$stringresult = ucwords($string);

the result will be
Name Sake

Categories
functions php

PHP: Function Explode

This function is used to break or split a string in php into a number of substrings based on the criteria you give. Like if you want to break a line into substrings with ‘:’ as delimiters

echo $pieces[$num].”
“;
}

?>

You will have the output as an array of strings…

anna
johnny
maria

It is really useful function when dealing with html codes or fetching files from other sites