0% found this document useful (0 votes)
64 views16 pages

W2 Lesson 2 PHP Basics - Presentation

The document outlines the objectives and topics to be covered in a PHP Basics module, including understanding PHP syntax, comments, variables, data types, and string concatenation. It provides examples and explanations of PHP syntax, comments, case sensitivity, variables, data types, and how to use echo, print, and string concatenation statements. The document also includes a machine problem asking to develop a form to collect customer data for a guest book for a real estate company.

Uploaded by

Wendell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views16 pages

W2 Lesson 2 PHP Basics - Presentation

The document outlines the objectives and topics to be covered in a PHP Basics module, including understanding PHP syntax, comments, variables, data types, and string concatenation. It provides examples and explanations of PHP syntax, comments, case sensitivity, variables, data types, and how to use echo, print, and string concatenation statements. The document also includes a machine problem asking to develop a form to collect customer data for a guest book for a real estate company.

Uploaded by

Wendell
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Week 002

PHP Basics
Objectives
• At the end of the module the student is expected to:
• Understand how to use PHP Syntax
• Understand and apply comments in PHP codes.
• Understand the concept of case sensitivity in PHP codes.
• Understand the use of variables.
• Understand and apply the use of echo and print
statements
• Understand the concept of data types and use it in PHP
programs
• Apply string concatenation
PHP BASICS
PHP Syntax
To embed PHP code, you must use the following syntax.

<?php
// PHP code goes here
?>

Every time you want to use php scripts, the codes must be enclose
inside <?php ?> , all codes that are place inside the php block are read
by the php.
PHP Comments
• A comment in PHP code is a line
that is not read/executed as part of
the program. Its purpose is to
provide information or details to the
codes.
• The following are the use of
comments.
• Let developers understand the code
you are writing.
• Serves as a reminder.
PHP Case Sensitivity
• In PHP, all keywords (e.g. if,
else, while, echo, etc.),
classes, functions, and user-
defined functions are NOT
case-sensitive. In the example
below, all three echo
statements below are legal
(and equal):
PHP Case Sensitivity
• Note: all variable names
are case-sensitive. In
the example below, only
the first statement will
display the value of the
$color variable (this is
because $color,
$COLOR, and $coLOR
are treated as three
different variables):
PHP Variables
• A variable can have a short name (like x and y) or a more descriptive
name (age, carname, total_volume).
• Rules for PHP variables:
• A variable starts with the $ sign, followed by the name of the
variable
• A variable name must start with a letter or the underscore character
• A variable name cannot start with a number
• A variable name can only contain alpha-numeric characters and
underscores (A-z, 0-9, and _ )
• Variable names are case-sensitive ($age and $AGE are two
different variables)
• Note: Remember that PHP variable names are case-sensitive
PHP Variables
PHP Data Types
PHP Data Types
PHP Variables
PHP Variables
String Concatenation

• The PHP concatenation operator (.) is used to combine 2 sting


values to create one string.
MACHINE PROBLEM
• You have been hired by DU30 Real Estate to develop a web site for their
company. They want to make sure they like your work so they will break
the project up into parts and have you develop one part at a time.
• You need to develop a form to collect customer data for a guest book. For
this first phase, you do not need to save the data entered at all... just
display it on a Web page.
• Make sure your Web Application meets the following criteria:
• 1. Put the DU30 Real Estate logo at the top of the page.
MACHINE PROBLEM

• 2. The customer should be able to enter their first and last name in
separate fields
• 3. Let the customer make a choice on whether they would like to be
contacted with their phone number or email and let them enter that
information only.
• 4. DU30 Real Estate only serves the following cities: Manila, Cebu,
and Davao. They
• should only be able to choose among those cities for potential places
to live.
• 5. Allow the user to enter comments.
• 6. Prove a submit button to send this information to the server.
MACHINE PROBLEM

• After the customer clicks the submit button:


• 1. Collect the information entered by the user.
• 2. Redisplay the information entered by the user being sure to indicate
their phone number or email, depending on what they entered in the
form.
• 3. The top of the page should include the company logo and a Thank
You message. Also, let them know that a representative will contact
them soon.
• 4. Be sure to display their comments in the same format as they
entered them but don't let them make any further changes to the text.

You might also like