Читать книгу PHP Programming for Beginners. Key Programming Concepts. How to use PHP with MySQL and Oracle databases (MySqli, PDO) - Sergey D Skudaev - Страница 2
Introduction
ОглавлениеDISCLAIMER
The information presented in this eBook is sold without warranty either expressed or implied. The author will hold no liability for any damages caused either directly or indirectly by the instructions contained in this book, or by the software products recommended for installation and usage.
Who Should Read This Book?
Those who wish to learn computer programming in PHP should be familiar with HTML, as a knowledge of HTML will be helpful in your efforts. This book is also for those who know other programming languages and wish to learn PHP as well.
PHP is a server-side scripting language executed on a web server, sending HTML pages to the browser. Included in the following are instructions for the installation of Apache Web Server, PHP, MySQL database, and phpMyAdmin script used for MySQL database administration. And please note that all of the above-mentioned software can be readily obtained and used free of charge.
Programming in any computer language or script is not as impossible as one might think.
Perhaps you’re thinking that being very good at math is a prerequisite to becoming a computer programmer, however, this is not necessarily so. The average person can master computer programming. In fact, a study revealed that, among immigrants, former musicians tended to make good programmers, probably because writing music is much like writing code.
In a sense, programming is like packaging something because programming language deals with variables that are used to hold different pieces of data. What is a variable? Think of a variable as you would a box for packaging. When you select a box, you must consider the size and nature of the item (s) being packaged.
Numbers, text strings, and objects are what comprise a computer program. A variable might contain whole numbers, fractions, or pieces or strings of text. A variable that contains a whole number is called an integer. A variable holding a number with a decimal point is called a float or double, while a variable holding a piece of text is called a string.
Computer programs begin with a variable declaration and, with some exceptions, the data type. For example, in C++ or Java, you must declare the variable name and exact data type. A variable name, in any computer language, must be only one word. It may contain alphabetical characters, numbers, and underscores. Often programmers use prefixes to show variable data types. For example, strName for a string data type or int_Account for an integer data type, and so on.
The integer, double, string, and date are all data types. Each data type requires a different “space” in the computer memory. For example, an integer occupies four bytes, or, because there are 8 bits to a byte, 32 bits – a bit being the smallest unit of information. A bit may contain a 0 or a 1. In the binary system 00000001 equals 1, 00000010 equals 2, 11111111 equals 256, or 2 to the 8th power.
Four bytes can hold numbers from -2,147,483,648 to +2,147,483,647.
A Double occupies 8 bytes. Huge numbers with decimals can be held in a double. A float occupies 4 bytes and can hold a number with decimals. When selecting a gift box for a diamond ring, you wouldn’t choose a yard-by-yard box because it wouldn’t be a very efficient way to package a ring. Likewise, with variables, you’ll want to declare the data types according to the space requirements for efficient use of computer memory.
When it is important that code lines are not broken in the script, but the page width does not allow for their display without breaking, I use <=> to indicate that this line of code is to be continued, uninterrupted, on one line uninterrupted.