Web Engineering (Lecture 09) PHP part I

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

Lecture 12. PHP. cp476 PHP

Web Engineering (Lecture 08) WAMP

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

PHP. Interactive Web Systems

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

PHP 03. Coding Style Self-processing pages Creating Memory Cookies Writing to a file Including Code Simple String Operations.

Princeton University COS 333: Advanced Programming Techniques A Subset of PHP

php Mr. Amit Patel Hypertext Preprocessor Dept. of I.T.

COMS 469: Interactive Media II

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:

WINTER. Web Development. Template. PHP Variables and Constants. Lecture

Introduction to string

Lambda Notes for CS 2102

MCIS/UA. String Literals. String Literals. Here Documents The <<< operator (also known as heredoc) can be used to construct multi-line strings.

Web Engineering (Lecture 06) JavaScript part 2

Assessment - Unit 3 lessons 16-21

Eastern Mediterranean University School of Computing and Technology Information Technology Lecture7 Strings and Characters

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

String Class in C++ When the above code is compiled and executed, it produces result something as follows: cin and strings

Server side basics CSC 210

ActiveNET. #202, Manjeera Plaza, Opp: Aditya Park Inn, Ameerpet HYD wwww.activenetinformatics.

PHP. Introduction. PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server

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

Reviewing all Topics this term

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Eastern Mediterranean University School of Computing and Technology Information Technology Lecture5 C Characters and Strings

Important Points about PHP:

ONE DIMENSIONAL ARRAYS

INTERVIEW QUESTIONS - PHP JOB 2014 (HTML)

C-String Library Functions

COMS W3101 Programming Language: C++ (Fall 2015) Ramana Isukapalli

Strings and Library Functions

Lecture 7 PHP Basics. Web Engineering CC 552

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

CSE 20. Lecture 4: Number System and Boolean Function. CSE 20: Lecture2

CS 177 Week 15 Recitation Slides. Review

COMP284 Scripting Languages Lecture 10: PHP (Part 2) Handouts

Web Programming Step by Step

Expressions and Variables

Shree Swaminarayan College of Computer Science. BCA-CC-404 Application Development Using VB.NET

Lecture 1. Types, Expressions, & Variables

Course: 501 : PHP & MySQL

Arrays intro (& strings) Ch 7

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

ARRAYS(II Unit Part II)

Logic - CM0845 Introduction to Haskell

Variables, Constants, and Data Types

Unit 1 - Arrays. 1 What is an array? Explain with Example. What are the advantages of using an array?

Object-oriented Programming for Automation & Robotics Carsten Gutwenger LS 11 Algorithm Engineering

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

Arrays (& strings) Ch 7

CMSC201 Computer Science I for Majors

5. Selection: If and Switch Controls

Compiler Construction LECTURE # 3

Basic PHP. Lecture 19. Robb T. Koether. Hampden-Sydney College. Mon, Feb 26, 2108

CS1 Lecture 3 Jan. 18, 2019

Chapter 11 Strings and Files. Starting Out with Games & Graphics in C++ Tony Gaddis

Introduction to JSON. Roger Lacroix MQ Technical Conference v

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

CS1 Lecture 3 Jan. 22, 2018

Creating HTML files using Notepad

CS 314 Principles of Programming Languages

Scheme as implemented by Racket

A very simple program. Week 2: variables & expressions. Declaring variables. Assignments: examples. Initialising variables. Assignments: pattern

CS107, Lecture 4 C Strings

CSE 115. Introduction to Computer Science I

MTAT Applied Cryptography

Dept. of Computer Sc., SDP College for Women, Ludhiana

Database Systems Fundamentals

PHP 1. Introduction Temasek Polytechnic

SYSC 2006 C Winter String Processing in C. D.L. Bailey, Systems and Computer Engineering, Carleton University

Introduction to Mathematical and Scientific Programming TUTORIAL WEEK 1 (MATH 1MP3) Winter 2019

CS 377 Database Systems. Li Xiong Department of Mathematics and Computer Science Emory University

CS107 Spring 2019, Lecture 4 C Strings

CS 106 Introduction to Computer Science I

User-defined Functions. Conditional Expressions in Scheme

How to work with strings and numbers

Chapter 9 How to work with strings and numbers

Dynamic Data Types - Recursive Records

Computers Programming Course 11. Iulian Năstac

1. Introduction to PHP 1.1 Installation of PHP and mysql 1.2 PHP configuration in IIS & Apache Web Server and features of PHP

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

CS 11 java track: lecture 1

Instructor s Notes Web Data Management PHP Sequential Processing Syntax. Web Data Management PHP Sequential Processing Syntax

Materials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.

Administration. Objects and Arrays. Objects. Agenda. What is an Object? What is a Class?

Sir Syed University of Engineering and Technology. Computer Programming & Problem Solving ( CPPS )

C does not support string data type. Strings in C are represented by arrays of characters.

PHP 101. Function Junction. Mike Pavlak Solutions Consultant (815) All rights reserved. Zend Technologies, Inc.

Open Source Web Application Development - CS310

CS31 Discussion 1E. Jie(Jay) Wang Week3 Oct.12

Chapter 5. Section 5.4 The Common String Library Functions. CS 50 Hathairat Rattanasook

First Java Program - Output to the Screen

Programming Language Concepts, cs2104 Lecture 04 ( )

PHP INTERVIEW QUESTION-ANSWERS

Characters in C consist of any printable or nonprintable character in the computer s character set including lowercase letters, uppercase letters,

Chapter 2.4: Common facilities of procedural languages

Programming in C++ PART 2

LISP - SEQUENCES. The function make-sequence allows you to create a sequence of any type. The syntax for this function is:

Transcription:

Web Engineering (Lecture 09) PHP part I By: Mr. Sadiq Shah Lecturer (CS) Class BS(IT)-6 th semester

PHP Data Types Variables can store data of different types, and different data types can do different things. PHP supports the following data types: String Integer Float (floating point numbers - also called double) Boolean Array Object NULL SM5312 week 5: web technology basics 2

PHP Array An array stores multiple values in one single variable. $cars = array("volvo","bmw","toyota"); PHP NULL Value $x = "Hello world!"; $x = null;

String Variables in PHP String variables are used for values that contain characters. A string can be used directly in a function or it can be stored in a variable. E.g. Echo Good morning ; OR $greetings = Good morning ; Echo $greetings;

The Concatenation Operator There is only one string operator in PHP. The concatenation operator (.) is used to put two string values together. $text1="hello "; $text2= Alice "; $text3="what a nice day!"; echo $text1. $text2. $text3;

1. The strlen() function The strlen() function is used to return the length of a string. echo strlen( google chrome ); Output: 13

2. The strpos() function The strpos() function is used to search for a character/text within a string If a match is found, this function will return the character position of the first match. If no match is found, it will return FALSE. E.g echo strpos("hello world!", w"); Output: 6

3. str_repeat() Function The str_repeat() function repeats a string a specified number of times. Syntax: str_repeat(string, repeat) Parameter string repeat Description It specifies the string to be repeated It specifies the number of times the string will be repeated. Must be greater or equal to 0 Example: echo str_repeat( Atif",10);

4. str_replace() Function The str_replace() function replaces some characters with some other characters in a string. Syntax: str_replace(find,replace,string) Parameter Description find Specifies the value to find replace Specifies the value to replace the value in find string Specifies the given string Example 1 echo str_replace( Roger","Peter","Hello Roger"); The output is: Hello Peter

5. str_word_count() Function The str_word_count() function counts the number of words in a string. Syntax: str_word_count(string) Example: echo str_word_count( Hi Good Morning ); Output: 3

6. strrev() Function The strrev() function reverses a given string. Syntax: strrev(string) Example: echo strrev( good morning ); Output: gninrom doog ih

7. strstr() function The strstr() function searches for the first occurrence of a string inside another string. This function returns the rest of the string (from the matching point), or FALSE, if the string to search for is not found. Syntax: strstr(string,search) Parameter string search Description Specifies the given string to search Specifies the string to search for. If this parameter is a number, it will search for the character matching the ASCII value of the number.

Strstr() function Example $search= This is BIT class ; echo strstr($search, B"); Output: BIT class

8. Strtolower() function strtolower() coverts a given string to its lower case format. Syntax: strtolower( string ) ; $lower=strtolower( Good Morning ); echo $lower; Output: good morning

9. Strtoupper() function Example strtoupper() coverts a given string to its upper case format. Syntax: strtoupper( string ) ; $upr=strtoupper( Good Morning ); echo $upr; Output: GOOD MORNING

9. Substr_replace() function substr_replace() replaces a string according a starting matching position. Syntax: substr_replace( string, replace,val1,val2); Val1 = starting point e.g. 3 Val2 = characters to be replace from starting point e.g 4 $string= goodmorning ; $result=substr_replace($string, evening,4,6); echo $result; Output: goodevening

Thank u