PHP. Interactive Web Systems

Size: px
Start display at page:

Download "PHP. Interactive Web Systems"

Transcription

1 PHP Interactive Web Systems

2 PHP PHP is an open-source server side scripting language. PHP stands for PHP: Hypertext Preprocessor One of the most popular server side languages Second most popular on GitHub (after Python) Supported by basically all non-iis web servers Very active development community Tons of learning resources

3 About PHP PHP has a syntax very similar to most other languages, including Java, which you should have some familiarity with: if (true) { print "Something!"; }

4 Using PHP PHP only works with a PHP Processor (generally on a server) Opening a PHP file in a web browser will not give an expected result Browsers don't "know" php Files must be place in a server directory Anywhere in your Cloud 9 workspace SECS Server: login.secs.oakland.edu Directory: ~/public_html

5 Using PHP PHP files use the.php extension Files without PHP will not have the code processed, and will be sent to the client All output from PHP is "text" in nature PHP does not have a direct user interface Even images are "text" behind the scenes PHP code must be placed within PHP tags <?php and?> Anything not within PHP tags is treated as a literal Meaning it is output directly

6 PHP Example PHP File: <!doctype html> <html> <title>my PHP</title> <body> <?php echo date('r');?> </body> </html> HTML Output to Client: <!doctype html> <html> <title>my PHP</title> <body> Tue, 10 Feb :23:21 </body> </html>

7 PHP BASICS

8 Comments in PHP To comment in php, you add //. Anything from there to the end of the line will be commented out echo Hello World"; //Output To comment out an entire block, start with /* and end with */ /* Everything in here is a "comment" print "even code"; */

9 Variables Used to store values for future use All variables must start with a $ Followed by a _ or letter, then combination of letters, numbers, and underscores Can only contain A-z, 0-9, and _ $myvar - Good $1var - Bad Case sensitive $myvar is not the same as $myvar

10 Variables PHP variables are loosely typed Their type is not declared, and may change over time Type is based on what you put into the variable Variables are declared implicitly You do not have to explicitly declare the variable, simply putting something into a variable creates it if it does not exist $username = john'; // string $points = 234; // integer $cost = 45.87; // float $response = true; // boolean

11 PHP Variable Types int, integer float, double, real string bool, boolean array resource NULL object

12 echo and print echo and print are used to output content such as strings and numbers (which will output as a string). The are basically identical Both may be used with or without () echo "Something"; echo("something"); print "Something"; print("something");

13 Arithmetic Order of Operations - Standard Parentheses ** (exponent) *, /, % (modulus), in left-to-right order +, -, in left-to-right order Use parentheses!!

14 Increment / Decrement Shorthand for increasing or decreasing a variable by one $a++ Post-increment $a-- Post-decrement Return $a then increment $a by one Return $a then decrement $a by one ++$a Pre-increment Increment $a by one, then return $a --$a Pre-decrement Decrement $a by one, then return $a $a = 8; echo $a++; 8 echo $a; 9 echo ++$a; 10 echo $a; 10

15 Concatenation Used to append strings together PHP uses the dot operator (. ) $new = $string1. $string2;

16 Assignment = assigns a value into a variable Shorthand assignment $a += $b is the same as $a = $a + $b +=, -=, *=, /=, %=,.=, **=

17 Comparison Operators Comparison operators apply the appropriate comparison to the items to the left and right, and "return" either true or false <, <= >, >= ==, === - Equality!=,!== - Not equality Not '='!

18 == vs === Two different equality operators == compares equality in value, but not necessarily type Ignores the distinction between: Integers, floating point numbers, and strings containing the same numeric value will return true Non-zero numbers and boolean TRUE Zero and boolean FALSE An Empty string or the string "0" and the boolean FALSE Any other non-empty string and boolean TRUE === compares equality in both value and type

19 Logical Operators $a && $b Logical And - True if $a and $b are True $a and $b Logical And $a $b Logical Or - True if either $a or $b are True $a or $b Logical Or $a xor $b Logical Xor - True if either $a or $b are True, but not both!$a Logical Not - True is $a is not True The difference between && and and (as well as and or) is that and and or have lower precedence than && and

20 Logical Operators - Short-circuiting All PHP logical operators skip evaluations if they can" false && never_runs() Never evaluates because && can now never return anything but false true never_runs() Never evaluates because can now never return anything but true

21 Operator ** Right Right! Right * / % Left + -. Left Associativity < <= > >= Non- Associative && Left Left = += -= *= **= / =.= %= and xor or Right Left Left Left ==!= ===!== <> Non- Associative Order of Operations

22 Order of Operations - Associativity When there are multiple operators of the same precedence, they are grouped based on their associativity: Left: $a + $b + $c is executed as ($a + $b) + $c Right: $a = $b = $c is executed as $a = ($b = $c) Non-Associative This means they cannot be used next to each other 0 < $a < 10 is not allowed in PHP

23 gettype() gettype() takes a variable and returns the name of the type $foo = "bar"; print gettype($foo); // Prints "string"

24 settype() settype() allows you to change the type of a variable: $foo = "3.14"; settype($foo, "int"); // $foo is now the integer 3

25 Converting Variable Types Casting $var = "3"; // String; $var2 = (int)$var; // Integer

26 STRINGS

27 Single and Double Quotes Single quotes - $str = 'My String'; Taken (almost) completely literally Does not replace variables or most escape sequences Double quotes - $str = "My String"; Processes string, looking for variable names Replaces standard escape sequences

28 Single and Double Quotes When a string is started by one type, only the same type can end it echo 'This is a string"; Parse error: syntax error, unexpected ''This is a string";' (T_ENCAPSED_AND_WHITESPACE) in /Users/merrill/test.php on line 3 echo 'This is a "quote"'; This is a "quote"

29 Escape Sequences Start with a \ - The next characters shows what to do: \n Replace with the newline character \r Replace with the return character \t Replace with a tab \\ Replace with a backslash \' Replace with a, not breaking the string \" Replace with a ", not breaking the string Single quote strings only replace \\ and \'

30 Escape Sequences print "This is\na new line"; This is a new line print 'This is\na new line'; This is\na new line

31 Escape Sequences echo "This is a "quote" of someone"; Parse error: syntax error, unexpected 'quote' (T_STRING), expecting ',' or ';' in /Users/merrill/test.php on line 3 echo "This is a \"quote\" of someone"; This is a "quote" of someone

32 Variable Replacement Searches double quote string for known variable and replaces them $type = "Dog"; print "This is a $type"; This is a Dog

33 Variable Replacement Use curly braces {} to make it less ambiguous $type = "Dog"; print "There are many $types"; Notice: Undefined variable: types in /Users/merrill/test.php on line 5 There are many $type = "Dog"; print "There are many {$type}s"; There are many Dogs

34 Aside - PHP Function Names Built in PHP functions do not follow a consistent naming scheme as you will see Frequently have to look up function name Good hinting text editor is very handy

35 Various String Functions strlen() Returns the number of characters in a string. str_word_count() Returns the number of words in a string. strrev() Returns a reversed version of the string

36 Various String Functions strpos() Returns the zero indexed position of the search item strpos("this is my string", "my"); //Returns 8 str_replace() Replace all instances of search with replacement in a string str_replace("re", "Dis", "Replace"); // Returns "Displace"

37 CONTROL STRUCTURES

38 if if (condition) { // Do something } else if (condition2) { // Do something } else { // Do something }

39 Ternary Operator PHP has a special conditional operator called the Ternary Operator: (condition)? (result 1) : (result 2) If the condition is true, then the operator evaluates to result 1 if the condition is false. then the operator evaluates to result 2 Very hard to read. I recommend against using it in general.

40 Ternary Operator $a = 6; echo $a > 5? "$a is >5" : "$a is <=5"; 6 is >5 A special note - the ternary operator is an expression which evaluates to a value, not a variable, this means: The results must be representable as a number or string If you assign the result of the expression into a variable, that variable will hold a copy of the value, not a reference to the selected variable

41 switch switch ($var) { case 1: // Do something break; case "b": // Do something break; default: // Do something }

42 Loops while: while (expression) { // Do something } for: for ($i = 0; $i < 10; $i++) { // Do something } do...while do { // Do something } while (expression);

43 ARRAYS

44 Aside - print_r() Used to output a variable in a human readable format, regardless of content. Mainly used for debugging $arr = array(); $arr[] = "0"; $arr[] = 0; $arr[] = false; $arr[] = null; print_r($arr); Array ( [0] => 0 [1] => 0 [2] => [3] => )

45 Aside - var_dump() Very similar to print_r(), but also includes information about the type and size of information within each variable $arr = array(); $arr[] = "0"; $arr[] = 0; $arr[] = false; $arr[] = null; var_dump($arr); array(4) { [0]=> string(1) "0" [1]=> int(0) [2]=> bool(false) [3]=> NULL }

46 Arrays Used to store many values Unlike Java, their size is not fixed, you can add and remove elements at any time Elements may be addressed by an integer or by string When a key is a number, it is an index When a key is a string, it is a name An array may have both index keys and name keys An array with key names is generally known as an Associative Array

47 Arrays - Creation All are valid: $arr1 = array(); $arr2 = array("val1", "val2", "val3"); $arr3 = array("key1" => "val1", $arr4[] = "val1"; "key2" => "val2"); $arr5 = ["val1", "val2", "val3"]; $arr6 = ["key1" => "val1", "key2" => "val2"];

48 Arrays - Appending Just assigning to $array[] will add the value to the end of the array, giving it a index one larger than the largest previously used number: $arr = array(); $arr[] = "val1"; $arr[5] = "val2"; $arr[] = "val3"; print_r($arr); Array ( [0] => val1 [5] => val2 [6] => val3 )

49 Arrays - Associative Use a string key instead of a index number: $arr = array(); $arr["key1"] = "val1"; $arr["key2"] = "val2"; print_r($arr); Array ( [key1] => val1 [key2] => val2 )

50 Arrays - foreach Loops through all the elements in an array: foreach ($arr as $element) { // Do something } Or foreach ($arr as $key => $element) { // Do something }

51 Arrays - Sorting sort() Sort array in ascending order rsort() Sort array in descending order asort() Sort associative array in ascending order by value ksort() Sort associative array in ascending order by key arsort() Sort associative array in descending order by value krsort() Sort associative array in descending order by key

52 Arrays - Sorting They sort "in place": $arr = array(5, 1, 2,6); sort($arr); print_r($arr); Array ( 0 => 1 1 => 2 2 => 5 3 => 6 )

53 FUNCTIONS

54 Functions Defined much like most other languages: function myfunction1() { // Do something } Name can start with an underscore or a letter (not a number Unlike variable names, function names are not case sensitive

55 Arguments When functions are defined with arguments (also known as parameters), those variables will exist in the function, with the values passed: function myfunction($param1, $param2) { echo $param1; echo $param2; } myfunction("one", "Two"); Arguments are pass OneTwo

56 Arguments Arguments are passed in the calling order, and have nothing to do with the names given: $var1 = "A"; $var2 = "B"; myfunction($var2, $var1); "B" "A" function myfunction($var1, $var2) { echo $var1; echo $var2; BA }

57 Default Argument Values You can define what will be used if the argument is not supplied: function myfunction($param1 = "One") { echo $param1; } myfunction(); One

58 Default Argument Values If a default is not defined, the argument is required! function myfunction($param1) { echo $param1; } myfunction(); Warning: Missing argument 1 for myfunction(), called in /Users/merrill/test.php on line 6 and defined in /Users/merrill/test.php on line 3

59 return Terminates the current function are "returns" control back to the calling function. If followed by a value, that value is returned to the location the function was called function myfunction() { return "Bob"; } print "My name is ". myfunction(); My name is Bob

What is PHP? [1] Figure 1 [1]

What is PHP? [1] Figure 1 [1] PHP What is PHP? [1] PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open source scripting language PHP scripts are executed on the server PHP is free to download and use Figure

More information

CSC Web Programming. Introduction to JavaScript

CSC Web Programming. Introduction to JavaScript CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its

More information

PHP 5 Introduction. What You Should Already Know. What is PHP? What is a PHP File? What Can PHP Do? Why PHP?

PHP 5 Introduction. What You Should Already Know. What is PHP? What is a PHP File? What Can PHP Do? Why PHP? PHP 5 Introduction What You Should Already Know you should have a basic understanding of the following: HTML CSS What is PHP? PHP is an acronym for "PHP: Hypertext Preprocessor" PHP is a widely-used, open

More information

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP

Copyright 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley. Chapter 11 Introduction to PHP Chapter 11 Introduction to PHP 11.1 Origin and Uses of PHP Developed by Rasmus Lerdorf in 1994 PHP is a server-side scripting language, embedded in XHTML pages PHP has good support for form processing

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

Full file at

Full file at Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class

More information

B. V. Patel Institute of BMC & IT 2014

B. V. Patel Institute of BMC & IT 2014 Unit 1: Introduction Short Questions: 1. What are the rules for writing PHP code block? 2. Explain comments in your program. What is the purpose of comments in your program. 3. How to declare and use constants

More information

Lecture 12. PHP. cp476 PHP

Lecture 12. PHP. cp476 PHP Lecture 12. PHP 1. Origins of PHP 2. Overview of PHP 3. General Syntactic Characteristics 4. Primitives, Operations, and Expressions 5. Control Statements 6. Arrays 7. User-Defined Functions 8. Objects

More information

Variables and literals

Variables and literals Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

More information

PHP by Pearson Education, Inc. All Rights Reserved.

PHP by Pearson Education, Inc. All Rights Reserved. PHP 1992-2012 by Pearson Education, Inc. All Client-side Languages User-agent (web browser) requests a web page JavaScript is executed on PC http request Can affect the Browser and the page itself http

More information

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37)

PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37) PHP Personal Home Page PHP: Hypertext Preprocessor (Lecture 35-37) A Server-side Scripting Programming Language An Introduction What is PHP? PHP stands for PHP: Hypertext Preprocessor. It is a server-side

More information

Visual C# Instructor s Manual Table of Contents

Visual C# Instructor s Manual Table of Contents Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms

More information

Variables, Constants, and Data Types

Variables, Constants, and Data Types Variables, Constants, and Data Types Strings and Escape Characters Primitive Data Types Variables, Initialization, and Assignment Constants Reading for this lecture: Dawson, Chapter 2 http://introcs.cs.princeton.edu/python/12types

More information

Lecture 7 PHP Basics. Web Engineering CC 552

Lecture 7 PHP Basics. Web Engineering CC 552 Lecture 7 PHP Basics Web Engineering CC 552 Overview n Overview of PHP n Syntactic Characteristics n Primitives n Output n Control statements n Arrays n Functions n WampServer Origins and uses of PHP n

More information

PHP: The Basics CISC 282. October 18, Approach Thus Far

PHP: The Basics CISC 282. October 18, Approach Thus Far PHP: The Basics CISC 282 October 18, 2017 Approach Thus Far User requests a webpage (.html) Server finds the file(s) and transmits the information Browser receives the information and displays it HTML,

More information

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley PHP and MySQL for Dynamic Web Sites Intro Ed Crowley Class Preparation If you haven t already, download the sample scripts from: http://www.larryullman.com/books/phpand-mysql-for-dynamic-web-sitesvisual-quickpro-guide-4thedition/#downloads

More information

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

More information

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Server side basics CS380

Server side basics CS380 1 Server side basics URLs and web servers 2 http://server/path/file Usually when you type a URL in your browser: Your computer looks up the server's IP address using DNS Your browser connects to that IP

More information

PHP Reference. To access MySQL manually, run the following command on the machine, called Sources, where MySQL and PhP have been installed:

PHP Reference. To access MySQL manually, run the following command on the machine, called Sources, where MySQL and PhP have been installed: PHP Reference 1 Preface This tutorial is designed to teach you all the PHP commands and constructs you need to complete your PHP project assignment. It is assumed that you have never programmed in PHP

More information

PHPoC Language Reference > Overview. Overview

PHPoC Language Reference > Overview. Overview PHPoC Language Reference > Overview Overview PHPoC (PHP on Chip) is a scripting language developed by Sollae Systems for programmable devices such as PHPoC Black, PHPoC Blue and etc. PHPoC is, as the name

More information

CS313D: ADVANCED PROGRAMMING LANGUAGE

CS313D: ADVANCED PROGRAMMING LANGUAGE CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting

More information

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel

Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Web Application Development (WAD) V th Sem BBAITM(Unit-1) By: Binit Patel Introduction: PHP (Hypertext Preprocessor) was invented by Rasmus Lerdorf in 1994. First it was known as Personal Home Page. Later

More information

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser:

URLs and web servers. Server side basics. URLs and web servers (cont.) URLs and web servers (cont.) Usually when you type a URL in your browser: URLs and web servers 2 1 Server side basics http://server/path/file Usually when you type a URL in your browser: Your computer looks up the server's IP address using DNS Your browser connects to that IP

More information

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables

Overview: Programming Concepts. Programming Concepts. Names, Values, And Variables Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript

Overview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating

More information

PHP Hypertext Preprocessor

PHP Hypertext Preprocessor PHP Hypertext Preprocessor A brief survey Stefano Fontanelli stefano.fontanelli@sssup.it January 16, 2009 Stefano Fontanelli stefano.fontanelli@sssup.it PHP Hypertext Preprocessor January 16, 2009 1 /

More information

CSCB20 Week 8. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2017

CSCB20 Week 8. Introduction to Database and Web Application Programming. Anna Bretscher* Winter 2017 CSCB20 Week 8 Introduction to Database and Web Application Programming Anna Bretscher* Winter 2017 *thanks to Alan Rosselet for providing the slides these are adapted from. Web Programming We have seen

More information

Chapter 17. Fundamental Concepts Expressed in JavaScript

Chapter 17. Fundamental Concepts Expressed in JavaScript Chapter 17 Fundamental Concepts Expressed in JavaScript Learning Objectives Tell the difference between name, value, and variable List three basic data types and the rules for specifying them in a program

More information

PHPoC vs PHP > Overview. Overview

PHPoC vs PHP > Overview. Overview PHPoC vs PHP > Overview Overview PHPoC is a programming language that Sollae Systems has developed. All of our PHPoC products have PHPoC interpreter in firmware. PHPoC is based on a wide use script language

More information

SECTION II: LANGUAGE BASICS

SECTION II: LANGUAGE BASICS Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators

More information

CSCI 1061U Programming Workshop 2. C++ Basics

CSCI 1061U Programming Workshop 2. C++ Basics CSCI 1061U Programming Workshop 2 C++ Basics 1 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output

More information

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy

COMP 2718: Shell Scripts: Part 1. By: Dr. Andrew Vardy COMP 2718: Shell Scripts: Part 1 By: Dr. Andrew Vardy Outline Shell Scripts: Part 1 Hello World Shebang! Example Project Introducing Variables Variable Names Variable Facts Arguments Exit Status Branching:

More information

Web Scripting using PHP

Web Scripting using PHP Web Scripting using PHP Server side scripting So what is a Server Side Scripting Language? Programming language code embedded into a web page PERL PHP PYTHON ASP Different ways of scripting the Web Programming

More information

PHPoC. PHPoC vs PHP. Version 1.1. Sollae Systems Co., Ttd. PHPoC Forum: Homepage:

PHPoC. PHPoC vs PHP. Version 1.1. Sollae Systems Co., Ttd. PHPoC Forum:  Homepage: PHPoC PHPoC vs PHP Version 1.1 Sollae Systems Co., Ttd. PHPoC Forum: http://www.phpoc.com Homepage: http://www.eztcp.com Contents 1 Overview...- 3 - Overview...- 3-2 Features of PHPoC (Differences from

More information

INTERNET PROGRAMMING. Software Engineering Branch / 4 th Class Computer Engineering Department University of Technology

INTERNET PROGRAMMING. Software Engineering Branch / 4 th Class Computer Engineering Department University of Technology INTERNET PROGRAMMING Software Engineering Branch / 4 th Class Computer Engineering Department University of Technology OUTLINES PHP Basic 2 ARCHITECTURE OF INTERNET database mysql server-side programming

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Conditional Statements String and Numeric Functions Arrays Review PHP History Rasmus Lerdorf 1995 Andi Gutmans & Zeev Suraski Versions 1998 PHP 2.0 2000 PHP

More information

JavaScript: Introduction, Types

JavaScript: Introduction, Types JavaScript: Introduction, Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 19 History Developed by Netscape "LiveScript", then renamed "JavaScript" Nothing

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

Java Basic Programming Constructs

Java Basic Programming Constructs Java Basic Programming Constructs /* * This is your first java program. */ class HelloWorld{ public static void main(string[] args){ System.out.println( Hello World! ); A Closer Look at HelloWorld 2 This

More information

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines. Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of

More information

Important Points about PHP:

Important Points about PHP: Important Points about PHP: PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking,

More information

Objectives. In this chapter, you will:

Objectives. In this chapter, you will: Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about

More information

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program

More information

CS4120/4121/5120/5121 Spring 2016 Xi Language Specification Cornell University Version of May 11, 2016

CS4120/4121/5120/5121 Spring 2016 Xi Language Specification Cornell University Version of May 11, 2016 CS4120/4121/5120/5121 Spring 2016 Xi Language Specification Cornell University Version of May 11, 2016 In this course you will start by building a compiler for a language called Xi. This is an imperative,

More information

JME Language Reference Manual

JME Language Reference Manual JME Language Reference Manual 1 Introduction JME (pronounced jay+me) is a lightweight language that allows programmers to easily perform statistic computations on tabular data as part of data analysis.

More information

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users

Let's Look Back. We talked about how to create a form in HTML. Forms are one way to interact with users Introduction to PHP Let's Look Back We talked about how to create a form in HTML Forms are one way to interact with users Users can enter information into forms which can be used by you (programmer) We

More information

Language Reference Manual

Language Reference Manual TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall

More information

Chapter 2. Lexical Elements & Operators

Chapter 2. Lexical Elements & Operators Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System

More information

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are

More information

Creating HTML files using Notepad

Creating HTML files using Notepad Reference Materials 3.1 Creating HTML files using Notepad Inside notepad, select the file menu, and then Save As. This will allow you to set the file name, as well as the type of file. Next, select the

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

PHP 1. Introduction Temasek Polytechnic

PHP 1. Introduction Temasek Polytechnic PHP 1 Introduction Temasek Polytechnic Background Open Source Apache License Free to redistribute with/without source code http://www.apache.org/license.txt Backed by Zend Corporation http://www.zend.com

More information

4 Programming Fundamentals. Introduction to Programming 1 1

4 Programming Fundamentals. Introduction to Programming 1 1 4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,

More information

Decaf Language Reference Manual

Decaf Language Reference Manual Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

JavaScript Functions, Objects and Array

JavaScript Functions, Objects and Array JavaScript Functions, Objects and Array Defining a Function A definition starts with the word function. A name follows that must start with a letter or underscore, followed by any number of letters, digits,

More information

2 rd class Department of Programming. OOP with Java Programming

2 rd class Department of Programming. OOP with Java Programming 1. Structured Programming and Object-Oriented Programming During the 1970s and into the 80s, the primary software engineering methodology was structured programming. The structured programming approach

More information

Web Engineering (Lecture 08) WAMP

Web Engineering (Lecture 08) WAMP Web Engineering (Lecture 08) WAMP By: Mr. Sadiq Shah Lecturer (CS) Class BS(IT)-6 th semester WAMP WAMP is all-in-one Apache/MySQL/PHP package WAMP stands for: i) Windows ii) iii) iv) Apache MySql PHP

More information

VLC : Language Reference Manual

VLC : Language Reference Manual VLC : Language Reference Manual Table Of Contents 1. Introduction 2. Types and Declarations 2a. Primitives 2b. Non-primitives - Strings - Arrays 3. Lexical conventions 3a. Whitespace 3b. Comments 3c. Identifiers

More information

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C Overview The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments

More information

Chapter 2: Using Data

Chapter 2: Using Data Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that

More information

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science)

The C Programming Language. (with material from Dr. Bin Ren, William & Mary Computer Science) The C Programming Language (with material from Dr. Bin Ren, William & Mary Computer Science) 1 Overview Motivation Hello, world! Basic Data Types Variables Arithmetic Operators Relational Operators Assignments

More information

Object oriented programming. Instructor: Masoud Asghari Web page: Ch: 3

Object oriented programming. Instructor: Masoud Asghari Web page:   Ch: 3 Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions

More information

egrapher Language Reference Manual

egrapher Language Reference Manual egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction

More information

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361)

Crayon (.cry) Language Reference Manual. Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) Crayon (.cry) Language Reference Manual Naman Agrawal (na2603) Vaidehi Dalmia (vd2302) Ganesh Ravichandran (gr2483) David Smart (ds3361) 1 Lexical Elements 1.1 Identifiers Identifiers are strings used

More information

Introduction to Databases. Key Concepts. Calling a PHP Script 5/17/2012 PHP I

Introduction to Databases. Key Concepts. Calling a PHP Script 5/17/2012 PHP I Introduction to Databases PHP I PHP in HTML Calling functions Form variables Identifies and data types Operators Decisions Conditionals Arrays Multi dimensional arrays Sorting arrays Array manipulation

More information

CS50 Supersection (for those less comfortable)

CS50 Supersection (for those less comfortable) CS50 Supersection (for those less comfortable) Friday, September 8, 2017 3 4pm, Science Center C Maria Zlatkova, Doug Lloyd Today s Topics Setting up CS50 IDE Variables and Data Types Conditions Boolean

More information

Java+- Language Reference Manual

Java+- Language Reference Manual Fall 2016 COMS4115 Programming Languages & Translators Java+- Language Reference Manual Authors Ashley Daguanno (ad3079) - Manager Anna Wen (aw2802) - Tester Tin Nilar Hlaing (th2520) - Systems Architect

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Project One PHP Preview Project One Grading Methodology Return Project One & Evaluation Sheet Project One Evaluation Methodology Consider each project in and of itself

More information

3 The Building Blocks: Data Types, Literals, and Variables

3 The Building Blocks: Data Types, Literals, and Variables chapter 3 The Building Blocks: Data Types, Literals, and Variables 3.1 Data Types A program can do many things, including calculations, sorting names, preparing phone lists, displaying images, validating

More information

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1

IDM 232. Scripting for Interactive Digital Media II. IDM 232: Scripting for IDM II 1 IDM 232 Scripting for Interactive Digital Media II IDM 232: Scripting for IDM II 1 PHP HTML-embedded scripting language IDM 232: Scripting for IDM II 2 Before we dive into code, it's important to understand

More information

Programming with C++ as a Second Language

Programming with C++ as a Second Language Programming with C++ as a Second Language Week 2 Overview of C++ CSE/ICS 45C Patricia Lee, PhD Chapter 1 C++ Basics Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Introduction to

More information

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

Java Bytecode (binary file)

Java Bytecode (binary file) Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.

More information

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.

Rule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead. Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

BEGINNER PHP Table of Contents

BEGINNER PHP Table of Contents Table of Contents 4 5 6 7 8 9 0 Introduction Getting Setup Your first PHP webpage Working with text Talking to the user Comparison & If statements If & Else Cleaning up the game Remembering values Finishing

More information

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on: Data and Expressions Data and Expressions Let's explore some other fundamental programming concepts Chapter 2 focuses on: Character Strings Primitive Data The Declaration And Use Of Variables Expressions

More information

Web Scripting using PHP

Web Scripting using PHP Web Scripting using PHP Server side scripting No Scripting example - how it works... User on a machine somewhere Server machine So what is a Server Side Scripting Language? Programming language code embedded

More information

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure

C OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces

More information

Computer Programming : C++

Computer Programming : C++ The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program

More information

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web

The PHP language. Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web Web programming The PHP language Our objective Teaching you everything about PHP? Not exactly Goal: teach you how to interact with a database via web Access data inserted by users into HTML forms Interact

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

JScript Reference. Contents

JScript Reference. Contents JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript

More information

Decaf Language Reference

Decaf Language Reference Decaf Language Reference Mike Lam, James Madison University Fall 2016 1 Introduction Decaf is an imperative language similar to Java or C, but is greatly simplified compared to those languages. It will

More information

JavaScript I Language Basics

JavaScript I Language Basics JavaScript I Language Basics Chesapeake Node.js User Group (CNUG) https://www.meetup.com/chesapeake-region-nodejs-developers-group START BUILDING: CALLFORCODE.ORG Agenda Introduction to JavaScript Language

More information

Programming for the Web with PHP

Programming for the Web with PHP Aptech Ltd Version 1.0 Page 1 of 11 Table of Contents Aptech Ltd Version 1.0 Page 2 of 11 Abstraction Anonymous Class Apache Arithmetic Operators Array Array Identifier arsort Function Assignment Operators

More information

ISA 563 : Fundamentals of Systems Programming

ISA 563 : Fundamentals of Systems Programming ISA 563 : Fundamentals of Systems Programming Variables, Primitive Types, Operators, and Expressions September 4 th 2008 Outline Define Expressions Discuss how to represent data in a program variable name

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University 1 And use http://www.w3schools.com/ JavaScript Objectives Introduction to JavaScript Objects Data Variables Operators Types Functions Events 4 Why Study JavaScript?

More information

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed

C OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages

More information

Your Secrets to Coding Fast

Your Secrets to Coding Fast Exclusive PHP Cheat-Sheet: Your Secrets to Coding Fast 1 INTRODUCTION If you re reading this, you probably know what PHP is, and might even be familiar all of the different functions it performs. In this

More information

Client-Side Web Technologies. JavaScript Part I

Client-Side Web Technologies. JavaScript Part I Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful

More information