Tham khảo sách 'easy php websites with the zend framework (phần 2)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 2 INTRODUCING PHP 31 Taking Advantage of Functions Earlier in this chapter you learned what a function is a bit of code packaged in such a way that it can be repeatedly executed by referring to its defined name. For example in this chapter you ve already encountered the printf function. As you might imagine PHP offers many more functions capable of performing a seemingly countless number of tasks ranging from rounding fractions down to counting the number of characters in a string to redirecting a visitor to another website. To obtain a better idea of just how many functions are at your disposal take some time to peruse PHP s manual. In this section you ll become better acquainted with functions by formally introducing a function you ll repeatedly return to when building PHP-powered websites. Introducing the date Function The date function is very powerful allowing you to format not only the current date but also the current time in a wide variety of ways. For example presuming today s date was July 4 2009 among many other formats you could easily output the current date and time using any of the following formats July 4 2009 07 04 2009 07 04 09 Saturday Sat 04 July 2008 The date function can also output the current time in a wide variety of formats such as 08 15 pm 20 15 11 40 am EST 11 40 am -0500 Although not mandatory many functions accept one or more input parameters which help determine how the function behaves. Indeed the date function accepts two a required parameter which tells it how to return the date and or time and an optional parameter which tells it to format a specific date and time in accordance with a supplied timestamp more about what a timestamp is in a moment . Additionally a function will always return a value even if that value is nothing or void as they say in computer science-ese . In the date function s case it returns a string consisting of the desired formatted date and time. NOTE. Typically you ll learn about a function by .