Time and Date Function

Image Source:

One of the most important simple functions we use when we work on PHP is the Time and Date functions. It performs two things. The Time () function being responsible for the assignment of each date and time, a number string that is based in seconds. The Date () function meanwhile, is responsible in formatting this number string into a human friendly display. There are also other important functions worth mentioning. The Mktime () function is utilized to generate artificially the time stamp for a certain date and time. It has the same function as the time() but its different because this is used for a particular date not necessarily the present day. In counting down function, there is a simple script that can be used , it called Countdown script.

HTTP ????


??????: content.answers.com

HTML?????????HTTP?????????????????????HTML??????????????????????????????????? HTML????????????????????HTML???????????????????????????????????????????HTTP??????????????????????????????????????????HTML????????????????????????HTTP????????????????????????????????????????????????

HTTP???????????????????????????????????????????????????? ????????????????????????????? ??????????????????

Whats next for PHP?

Image Source:filemaker.com

When you’ve finished studying the learning curbs of PHP5, you will most likely wonder what is in store for PHP development in the near future. Where will this indispensable programming language headed in the next year? As we all know, PHP 5 has been a very significant development for the programming language. PHP5 has simply set the standard of many features that had little support before. Or simply was not focused on. It revolutionized the language, practically. And it really live up to its predecessor, PHP4. PHP5 as major version will be around 3 to 4 years much like PHP4 which was released in 2000. It had undergone a number of important revisions as it moved along. Definitely, PHP5 will see some minor patch releases. it will correct bugs from the original PHP5 . But it definitely will provide us with newest functionalities to use and do things with. So enjoy using your favorite PHP5. It will be here to stay and be helpful to you.

The HTTP Header


Image Source: content.answers.com

People who are just starting to learn HTML may hear developers terms such as HTTP header and simply think that it is the same with a header of an HTML document. Big Mistake. The HTML header is anything you write in between the tags. The HTML header usually contains information about the page. The author provides the info for the client. The HTTP header, otherwise, is information the client and the server provides with each other regarding the transmission process of the document. Think of the HTML header as the date and address written at the top of a business letter, while the HTTP header is the address written on the envelope. They are both addresses, written in two different locations.

The HTTP header contains details about the transaction between the client and server, with slight variations depending on whether it is a request or a response. The header information can be grouped into three different categories. Namely, General, Entity, and Request/Response

Things To Remember on PHP


Image Source:www.faqs.org

Do you know what if felt like when you’re forgetting something and you promised to remember even just for one day? It felt like not having sessions in your website. Sessions in PHP temporarily saves important data that is needed for browsing the whole site, into the server for future references. Therefore, it will not take any of the user’s memory space. In our school, session is commonly used when the user has to log in first before entering. With session, his username and password won’t have to be displayed in the address bar, or the programmer won’t have to use POST for all of his pages. There are three functions used in PHP for session. Session_start() is used for starting a session and must always be placed before the body tag. It creates a unique id (UID) for the user. Session_unset() removes all of the values stored in the session. Session_destroy() deletes the UID. To store data as a session variable, user $_SESSION[‘variablename*’] and equate it to the value you want to save.

*Can be changed into what the user prefers.

Arrays : Changing cases

This form of array declaration allows one to change the case from uppercase to lowercase and vice versa. The syntax goes as follows:

array_change_key_case(array,case)

The array part, specifies which table or array to use and is a required field which is not the case with the key which is automatically assigned a value. An example of it’s use can be seen below:

$a=array('a'=>“Mouse”,’b'=>”Rat”,’c'=>”Rodent”,’d'=>”Cat”);
print_r(array_change_key_case($a,CASE_UPPER));
?>

The output of the said commands will be:
Array ( [A] => Mouse [B] => Rat [C] => Rodent [D] => Cat)

Another example of it’s use would be:

$a=array('a'=>“Mouse”,’B'=>”Rat”,’c'=>”Rodent”,’b'=>”Cat”);
print_r(array_change_key_case($a,CASE_UPPER));
?>

That returns the following values respectively:
Array ( [A] => Mouse [B] => Rat [C] => Rodent [D] => Cat)

In the next post, we would discuss an array function that divides a large array into several chunks of separate arrays.

Getting Started with PHP Programming

The first step to get us on our way to programming in PHP would be to set up an ideal development environment. You need a Web Server software like Apache (which would be what we are going to use) which is only one of many out there. Most of these web servers are open-source meaning that they are free. Now, being free doesn�t mean that they are not up to standards for there are standards that are set by independent groups that are comprised of the many developers who together formulate or give a loosely defined set of standards for others to follow. Apache has versions for Linux but there are also for the Windows, Unix and Mac OS. The installer can be downloaded along with the detailed manual from PHP.net

Post Variable Continued and the $_REQUEST variable

The “welcome.php” file can now utilize the $_POST variable to catch the data contained within the form as with the request variable in the previous posts, the form fields will automatically be the ID keys in the $_POST array. This variable would be very useful for passwords and user name and other entry forms (having no limits on length) but being so discreet, it cannot be bookmarked.

Welcome .

You are years old!

The $_REQUEST Variable
The variable contains the contents of both $_GET, $_POST and $_COOKIE which can be used to get the result from the data sent with the GET and POST methods like the sample shown below.

Welcome .

You are years old!

Functions with Parameters

Now, the first sample PHP function did something very simple that it displayed a string that does not change and was not influenced by any parameters. We then move to show functions with one or more parameters that make them more powerful and diverse. That is done by placing these parameters inside the “()”.


function displayMyName($myfName,$mark)
{
echo $myfName . "Dela Cruz" . $mark . "
“;
}
echo “My name is”;
$displaymyName(“Juan”,”.”)
echo “My name is”;
$displaymyName(“Jack”,”.”)
echo “My name is”;
$displaymyName(“June”,”.”)
?>


The output of the sample would be :

My name is Juan Dela Cruz
My name is Jack Dela Cruz
My name is June Dela Cruz

Error messages in PHP 5 has been upgraded! SWEET!

php5-6-0.png
Sometimes, the things matters. If you write this test program in PHP 4 (tested on 4.4.7):

< ?php
function test($arg) { echo "talk like a parrot."; }
test();
?>

An error message pops up like the one below:

Warning: Missing argument 1 for test() in /usr/bin/- on line 2

The error warning illustrates the position of the purpose of the function, but really the mistake was in how the function was called. The necessary parameter to test did not go smoothly. This error will most likely irk you, forcing you to check a stack trace and find the actual error. For beginners, this maybe a death sentence.

But if you are using the new PHP 5 and run the same message, it will come out like this:

Warning: Missing argument 1 for test(), called in /Users/john/- on line 3 and defined in /Users/john/- on line 2

Awesome Improvement!