1. Trang chủ
  2. » Công Nghệ Thông Tin

PHP 5 Recipes A Problem-Solution Approach PHẦN 1 docx

68 310 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 68
Dung lượng 2,03 MB

Nội dung

[...]... while PHP variables can and will change data types on the fly, ways still exist to force a variable to retain a certain data type PHP supports both typecasting and methods that can force a variable into a certain data type Table 1- 1 lists PHP 5 s data types Table 1- 1 PHP 5 Data Types Data Type Description Boolean Stores either a true or false value Integer Stores a numeric value that is a whole number... given variable a data type and then assign a value to it (as in languages such as C++ and Java), PHP automatically assigns a data type to a variable when a value is allocated to it This makes PHP rather simple to use when declaring variables and inputting values into them PHP variables, of course, follow a certain set of rules All variables must begin with $ and must be immediately followed by a letter... formidable set of array functionality Many types of arrays are available to you in PHP 5, and you have many different ways to work with them PHP 5 fully supports regular arrays, multidimensional arrays, and even the handy associative array Unlike the string functions available to PHP the array functions are , actually rather well organized and follow fairly easy-to-use naming conventions that make it... information will be checked and posted on the errata page or used in subsequent editions of the book You can view errata from the book’s detail page xxi 50 92_Ch00_FM_FINAL 8/26/ 05 5:32 PM Page xxii df1e604794cb6d1 915 bbedb2 613 cdeee 50 92_Ch 01_ FINAL 8/26/ 05 9: 45 AM CHAPTER Page 1 1 ■■■ Overview of PHP Data Types and Concepts P HP began life as a way to manage a small personal website and was imagined and... a simple example of how to set up an array in PHP 5 The Code < ?php //sample1_3 .php //Set up a standard array $myarray = array( "1" ,"2","3"); //You can access values from the array as simply as this: echo $myarray[0]; //Would output "1" //Or with a for loop for ($i = 0; $i < count ($myarray); $i++){ echo $myarray[$i] ""; } 5 5092_Ch 01_ FINAL 6 8/26/ 05 9: 45 AM Page 6 1- 4 ■ STRINGS //Setting up an... new PHP 5 release However, before we dive into that, in this chapter we will give you a simple overview of what PHP can do, what is new with PHP 5, and how you can apply these new concepts 1 50 92_Ch 01_ FINAL 2 8/26/ 05 9: 45 AM Page 2 1- 1 ■ VARIABLES 1- 1 Variables Variables in PHP are handled somewhat differently than in other similar programming languages Rather than forcing the developer to assign a given... in-depth explanation of numbers and some helpful real-world examples (including a static math class), skip ahead to Frank M Kromann’s detailed explanation on PHP 5 s number crunching in Chapter 3 1- 3 Arrays One of PHP 5 s major strengths resides in its rather powerful and verbose array processing capabilities Those familiar with a programming language such as C++ will feel right at home, as PHP 5 has a truly... the data you want gets put into your data storage agents and only the data you want to be visible makes its appearance on your web pages Setting up and working with both strings and substrings is effortless with PHP 5, as the following example demonstrates 50 92_Ch 01_ FINAL 8/26/ 05 9: 45 AM Page 7 1 -5 ■ REGULAR EXPRESSIONS The Code < ?php //sample1_4 .php //Because PHP determines the data type when a value... variables in depth 3 50 92_Ch 01_ FINAL 4 8/26/ 05 9: 45 AM Page 4 1- 2 ■ NUMBERS 1- 2 Numbers As any good programming language should be able to, PHP is more than capable of taking care of any math problems you may have PHP 5 is especially flexible when dealing with numbers because its variable accessing is so simple That being said, you must exert a certain degree of caution while working with said variables... type of a variable, it is not always best to use settype() to assign a data type to a variable PHP supports the concept of data typing, which will allow you to force a variable into a specific data type Not only is this fast and efficient, but you can use it much more cleanly in scripts For example: 11 50 92_Ch 01_ FINAL 12 8/26/ 05 9: 45 AM Page 12 1- 8 ■ PROJECT: DISCOVERING WHAT VARIABLES, CONSTANTS, FUNCTIONS, . class="bi x0 y0 w0 h0" alt="" PHP 5 Recipes A Problem-Solution Approach Lee Babin, Nathan A. Good, Frank M. Kromann, Jon Stephens 50 92_Ch00_FM_FINAL 8/26/ 05 5:32 PM Page i PHP 5 Recipes: A Problem-Solution. information on translations, please contact Apress directly at 256 0 Ninth Street, Suite 219 , Berkeley, CA 94 710 . Phone 51 0 -54 9 -59 30, fax 51 0 -54 9 -59 39, e-mail info@apress.com, or visit http://www.apress.com. The. 1 -59 059 -50 9-2 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked

Ngày đăng: 12/08/2014, 16:20

TỪ KHÓA LIÊN QUAN