0% found this document useful (0 votes)
20 views17 pages

Introduction To Programming in PHP: Lecture 1 - Getting Started

This document provides an introduction and overview of PHP, a server-side scripting language commonly used for building dynamic websites and web applications. It discusses some key PHP concepts like code blocks, functions vs language constructs, variables, constants, comments, and case sensitivity conventions. The agenda outlines topics that will be covered, including basic PHP scripts, variables, constants, functions, comments, and case sensitivity best practices. PHP allows embedding scripting code into HTML documents and is often used with databases to power forums, content management systems, and wikis.

Uploaded by

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

Introduction To Programming in PHP: Lecture 1 - Getting Started

This document provides an introduction and overview of PHP, a server-side scripting language commonly used for building dynamic websites and web applications. It discusses some key PHP concepts like code blocks, functions vs language constructs, variables, constants, comments, and case sensitivity conventions. The agenda outlines topics that will be covered, including basic PHP scripts, variables, constants, functions, comments, and case sensitivity best practices. PHP allows embedding scripting code into HTML documents and is often used with databases to power forums, content management systems, and wikis.

Uploaded by

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

Introduction to programming in PHP

Lecture 1 – Getting started


IBM 1994

PHP ›PHP: Hypertext Preprocessor

+ database

server-side scripting language

Forums/CMS/Wiki’s
Website calling without PHP
Websites calling with PHP
Agenda

 Basic PHP scripts


 Code (declaration) Blocks
 Functions vs Language Constructs
 Comments
 Variables
 Constants
 Case Sensitivity / Conventions
Scripts
<!DOCTYPE html>
<html>
<head>
<meta charset=“UTF-8”>
<title>
<?php
//code block 2
?>
</title>
</head>
<body>
<?php

?>
</body>
</html>
Scripts

<?php
// statements
?>
Code (declaration) Blocks

 <?php statements; ?>

 <script language=“php”> statements; </script>

 <? statements; ?>

 <% statements; %>


Functions vs language constructs

<?php
// comments
echo “Hello World!”;
print “Hello World!”;
?>
Comments
Line Comment
// This is a line comment.
# This is a line comment as well.

Block Comment
/* This is a block comment. It (mostly) consists of
multiple lines and has an opening and closing
comment sign. */
Scripts

<?php
// calling functions
phpinfo();
?>
Variables

! $nameVariable = value;

identifier

$age = 18;
echo “<p>My age is “ . $age . “.</p>”;
Constants

! define(“NAME_CONSTANT”, value);

identifier

define(“AGE”, 18);
echo “<p>My age is “ . AGE . “.</p>”;
Scripts

<?php
// calling functions
$round = 3.356;
echo round($round); parameter

// or
echo round(3.356); argument
?>
Scripts

<?php
// calling functions
$stomach = “”;
if(empty($stomach))
{
echo “Grumble, grumble!”;
}
?>
string
Case Sensitivity / Conventions

Case sensitive Case insensitive

variables functions
constants keywords and constructs
(if, else, null, foreach, echo etc.)

 Be consistent!
 Result:
 Clear code (no chaos!);
 Less errors.
Questions?

You might also like