0% found this document useful (0 votes)
96 views9 pages

ITWM132 - Module 0 - Review

This document provides an introduction to PHP for a class. It summarizes that PHP is a scripting language suited for web development. It can be embedded into HTML files and parsed by a web server. The document outlines that PHP requires a web server and browser to run, and recommends using XAMPP, which includes Apache and MySQL. It then discusses PHP variables and data types, expressions, operators, control structures, functions, and provides instructions for creating a basic "Hello World" PHP script to run locally using XAMPP.

Uploaded by

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

ITWM132 - Module 0 - Review

This document provides an introduction to PHP for a class. It summarizes that PHP is a scripting language suited for web development. It can be embedded into HTML files and parsed by a web server. The document outlines that PHP requires a web server and browser to run, and recommends using XAMPP, which includes Apache and MySQL. It then discusses PHP variables and data types, expressions, operators, control structures, functions, and provides instructions for creating a basic "Hello World" PHP script to run locally using XAMPP.

Uploaded by

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

ITWM132 Module 0

Prepared by:
Naycer Jeremy G. Tulas
n.tulas@bsu.edu.ph
09129412101
https://www.facebook.com/naycer.tulas
Review – What is PHP
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open-source
general-purpose scripting language that is especially suited for web development and can
be embedded into HTML. For example:

PHP pages contain HTML with embedded code that does "something" (in this case, output
"Hi, I'm a PHP script!"). When PHP parses a file, it looks for opening and closing tags, which
are <?php and ?> which tell PHP to start and stop interpreting the code between them.
Parsing in this manner allows PHP to be embedded in all sorts of different documents, as
everything outside of a pair of opening and closing tags is ignored by the PHP parser.

PHP requires two basic components to run; a web server and a browser. For the purposes of
this class, we will be using Apache as our web server. But to make it more convenient we
will be using the XAMPP package which includes not only Apache but MySQL as well. You
are free to choose which browser (Firefox, Google Chrome, Edge, etc..) and which text-
editor (Sublime Text, Visual Studio, Notepad ++, etc..) to use.

Variables and Data Types


Variables in PHP are represented by a dollar sign followed by the name of the variable. The
variable name is case-sensitive.
Variable names follow the same rules as other labels in PHP. A valid variable name starts
with a letter or underscore, followed by any number of letters, numbers, or underscores.

PHP supports ten primitive types.

Four scalar types Four compound types Two special types

● bool ● array ● resource


● int ● object ● NULL
● float ● callable
● string ● iterable

We will be more commonly working with bool, int, float, string, array, and object.

PHP is loosely typed. Meaning that you do not need to declare the type, the parser will infer
it from your code. This is known as type juggling.

An array stores multiple values in one single variable. Classes and objects are the two main
aspects of object-oriented programming. A class is a template for objects, and an object is
an instance of a class.

Expressions
Expressions are the most important building blocks of PHP. In PHP, almost anything you
write is an expression. The simplest yet most accurate way to define an expression is
"anything that has a value".
The most basic forms of expressions are constants and variables. When you type $a = 5,
you're assigning 5 into $a. 5, obviously, has the value 5, or in other words 5 is an expression
with the value of 5 (in this case, 5 is an integer constant).

After this assignment, you'd expect $a's value to be 5 as well, so if you wrote $b = $a, you'd
expect it to behave just as if you wrote $b = 5. In other words, $a is an expression with the
value of 5 as well. If everything works right, this is exactly what will happen.

Operators
PHP, just like any other programming language, has support for various operators like
arithmetic operators, assignment operators, logical operators, and others.

Control Structures/Statements
Any PHP script is built out of a series of statements including control statements/structures.
The various control structures are described here.

Functions
A function may be defined using syntax such as the following:

Any valid PHP code may appear inside a function, even other functions and class definitions.
Function names follow the same rules as other labels in PHP. A valid function name starts
with a letter or underscore, followed by any number of letters, numbers, or underscores.
Running Your First PHP Script
Download XAMPP from here. I am assuming that all of us are using Windows (either 7 or 10)
64-bit. Make sure that you download version 8.1.6.

Follow the installation instructions. Keep the default settings especially the installation
folder so that all further instructions are uniform.

From now on, every time we want to use PHP. We should start the Apache Module from
the XAMPP control panel.
Navigate to Local Disk C:\xampp\htdocs. All your future projects will be stored here. Create
a folder and name it ITWM132.

The server looks for specifically named files as the first page of your website, also known as
the index page. The default order of index file names our particular servers look through is
index.htm, index.html, index.php, and finally default.htm.
Inside the ITWM132 folder, create an index.php file. You can use any text editor to edit the
index.php file. I will personally be using Sublime Text 3.

Copy and paste the code below into your index.php. The short snippet below demonstrates
simple concepts such as variable declaration, assignment operators, and a basic control
statement.

You can access your page by opening any web browser and navigating to
http://localhost/ITWM132/

Try to toggle the control statement by setting the variable $show_last_name to false.
? Module 0: Quiz and Laboratory Activity
(Answer in respective Google Classrooms)

------ END OF MODULE ------

Prepared by:
Naycer Jeremy G. Tulas
n.tulas@bsu.edu.ph
09129412101
https://www.facebook.com/naycer.tulas

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy