ICT 5 Web Development - Chapter 2: PHP Variables and HTML Input Forms

ICT 5 Web Development - Chapter 2: PHP Variables and HTML Input Forms PHP Variables, Working with PHP String Variables, HTML Input Forms, HTML Input Forms and PHP Scripts, Selecting Variable Names. | Vietnam and Japan Joint ICT HRD Program Objectives To learn how to store and access data i d t in PHP variables i bl To understand how to create and manipulate numeric and string variables To review how to create HTML input forms To learn how to pass data from HTML forms to PHP scripts ITC 5 – Web Programming Chapter 2. PHP Variables and HTML Input Forms Nguyen Thi Thu Trang trangntt@ 2 Content Content 1. PHP Variables 2. Working with PHP String Variables 3. HTML Input Forms 4. HTML Input Forms and PHP Scripts 1. PHP Variables 2. Working with PHP String Variables 3. HTML Input Forms 4. HTML Input Forms and PHP Scripts 3 4 1 . Assigning New Values to Variables 1. PHP Variables You can assign new values to variables: $days = 3 $d 3; $newdays = 100; $days = $newdays; Variables are used to store and access data in computer memory. d t i t A variable name is a label used within a script to refer to the data. At the end of these three lines, $days and $newdays b th have values of 100. $ d both h l f 100 5 6 Selecting Variable Names Combining Variables and the print Statement You can select just about any set of j y characters for a variable name in PHP, but they must: That is, to print out the value of $x, is $x write the following PHP statement: – Use a dollar sign ($) as the first character – Use a letter or an underscore character (_) as the second character. – print ("$x"); Note:Try to select variable names that h l l i bl h help describe their function. For example $counter is more descriptive than $c or $ctr. 7 The following code will output “Bryant s yea s o d is 6 years old”. $age=6; print ("Bryant is $age years old."); 8 2 A Full Example . A Full Example . The previous code can be executed at p // / p ppg / / p p 1. 2. Variable Example / / 3. 4. second_num=$second_num"); second_num=$second_num"); 11. ?> 9 . Using Arithmetic Operators 10 Common PHP

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.