Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
PHP Crash Course CHAPTER 1 25 One important difference between constants and variables is that when you refer to a constant, it does not have a dollar sign in front of it. If you want to use the value of a constant, use its name only. For example, to use one of the constants we have just created, we could type: echo TIREPRICE; 1 PHP CRASH COURSE As well as the constants you define, PHP sets a large number of its own. An easy way to get an overview of these is to run the phpinfo() command: phpinfo(); This will provide a list of PHP’s predefined variables and. | PHP Crash Course Chapter 1 25 One important difference between constants and variables is that when you refer to a constant it does not have a dollar sign in front of it. If you want to use the value of a constant use its name only. For example to use one of the constants we have just created we could type echo TIREPRICE As well as the constants you define PHP sets a large number of its own. An easy way to get an overview of these is to run the phpinfo command phpinfo This will provide a list of PHP s predefined variables and constants among other useful information. We will discuss some of these as we go along. Variable Scope The term scope refers to the places within a script where a particular variable is visible. The three basic types of scope in PHP are as follows Global variables declared in a script are visible throughout that script but not inside functions. Variables used inside functions are local to the function. Variables used inside functions that are declared as global refer to the global variable of the same name. We will cover scope in more detail when we discuss functions. For the time being all the variables we use will be global by default. Operators Operators are symbols that you can use to manipulate values and variables by performing an operation on them. We ll need to use some of these operators to work out the totals and tax on the customer s order. We ve already mentioned two operators the assignment operator and . the string concatenation operator. Now we ll look at the complete list. In general operators can take one two or three arguments with the majority taking two. For example the assignment operator takes two the storage location on the left-hand side of the symbol and an expression on the right-hand side. These arguments are called operands that is the things that are being operated upon. 1 PHP Crash Course 26 Using PHP Part I Arithmetic Operators Arithmetic operators are very straightforward they are just the normal mathematical .