MCIS/UA. String Literals. String Literals. Here Documents The <<< operator (also known as heredoc) can be used to construct multi-line strings.
|
|
- Anna Lyons
- 5 years ago
- Views:
Transcription
1 MCIS/UA PHP Training 2003 Chapter 6 Strings String Literals Single-quoted strings Double-quoted strings escape sequences String Literals Single-quoted \' - single quote \\ - backslash Interpreted items variables \n \r \t \\ \$ \" \nnn \xnn Double-quoted - value of variable - new line - return - tab - backslash - dollar sign - double quote - ASCII char in octal - ASCII char in hex heredoc Here Documents The <<< operator also known as heredoc) can be used to construct multi-line strings. $mystring = <<< End This is a multi-line string. This is the second line. This is the third line. End; print $mystring; This is a multi-line string. This is the second line. This is the third line.
2 Here Documents $name = $info->queryfirstcolumn "SELECT name ". "FROM info ". "WHERE uniqueid =?", $uid); $sql = <<< end_of_sql SELECT name FROM info WHERE uniqueid =? end_of_sql; $name = $info->queryfirstcolumn$sql, $uid); Here Documents $name = $info->queryfirstcolumn<<< end_of_sql SELECT name FROM info WHERE uniqueid =? end_of_sql, $uid); outputting Outputting strings Several ways to output strings and other data: echo print printf sprintf print_r var_dump echo and print echo and print echo and print output data and are pretty much identical $x = "abc"; echo "value: $x"; value: abc print "value: $x"; value: abc printf
3 printf printf outputs formatted data $x = 5; printf"value: %d", $x); value: 5 $mon = 4; $day = 8; $year = 2003; printf"%d/%d/%d", $mon, $day, $year); 4/8/2003 format codes printf Format Codes format result input output %% %d %f %s %b %c %o %x %X %u percent sign integer floating point string binary character octal hex lowercase) hex uppercase) unsigned integer abc % abc 101 A bcd15 75BCD modifiers printf Additional modifiers may be added between the % and the letter in the following order) 0 - do zero padding rather than space padding minus sign - forces left-justification number - minumum number of characters to output; for floats - number of digits before the decimal point.number - for floats, the number of decimal digits modifier examples printf printf"%5d", 3); printf"%-5d", 3); 3 3 printf"%05d", 3); printf"%8f", 3.5); printf"%8.3f", 3.5); printf"%08.3f", 3.5);
4 printf $mon = 4; $day = 8; $year = 2003; printf"%d/%d/%d", $mon, $day, $year); 4/8/2003 printf"%02d/%02d/%04d", $mon, $day, $year); 04/08/2003 sprintf sprintf sprintf formatted data and returns a string $x = sprintf"%05d", 3); print $x; print_r print_r print_r can be used to dump variables $x = array1, "abc", array"covertka" => "Kent", "kingmatm" => "Tim")); print_r$x); [0] => 1 [1] => abc [2] => [covertka] => Kent [kingmatm] => Tim ) ) var_dump var_dump var_dump can also be used to dump variables $x = array1, "abc", array"covertka" => "Kent", "kingmatm" => "Tim")); var_dump$x); array3) { [0]=> int1) [1]=> string3) "abc" [2]=> array2) { ["covertka"]=> string4) "Kent" ["kingmatm"]=> string3) "Tim" } } string functions
5 Useful string functions There are many functions that can be used to manipulate strings: strlen) - string length trim), ltrim), rtrim) - trim strings strtoupper), strtolower) - change case ucfirst), ucwords) - uppercases the first character or first character of all words of a string Useful string functions substr) - returns part of a string strpos) - finds a substring within string explode) - splits a string into parts based on a seperator - returns an array implode) - concatenates all of the elements of an array together separated by a character Useful string functions str_repeat) - used to repeat a string a number of times str_pad - pads a string with another string to a particular length left, right, or both) strcasecmp) - compares 2 strings ignoring case parse_url) - parses a URL into it's parts scheme, host, port, path, etc.) Useful string functions htmlentities), htmlspecialchars) - encodes html special characters < > & ' ", etc.) rawurlencode), rawurldecode), urlencode), urldecode) - encodes a URL regular expressions
6 Regular Expressions preg_match'/\d\d\d-\d\d\d\d/', $phone); preg_match'/\d\d\d-)?\d\d\d-\d\d\d\d/', $phone); 513) or 513) preg_match'/\?\d\d\d-)?\)?\s?\d\d\d-\d\d\d\d/', $phone); parse the parts into variables preg_match'/\?\d\d\d)?-?\)?\s?\d\d\d)-\d\d\d\d)/', $phone, $parts); Regular Expressions The regular expression functions are used to perform various pattern matching activities: preg_match), preg_match_all) - match and extract) a pattern or all patterns from a string. preg_replace) - replace substrings that match a pattern with another substring. preg_split) - split a string based on a pattern. preg_grep) - find all elements of an array that match a pattern. Regular Expressions $x = 'abcdefghijk'; if preg_match'/def/', $x)) { print "Found the string."; } patterns are enclosed within delimiters - usually slashes /def/
7 Some characters have special meanings Matches Pattern True False. any single characters /c.t/ cat, execute coat ^ beginning of string /^cat/ cat, caterpiller application $ end of string /cat$/ cat, wildcat application or /cat dog/ application, dogged \b word boundary /\bcat/ cat, catalog, big cat wildcat \B non-word boundary /\Bcat/ wildcat cat, catalog Matches Pattern True False \s whitespace /c\st/ mac technology cat \S non-whitespace /c\st/ application mac tech \w word character 0-9,az,A-Z,_) /c\wt/ cat, application c$t \W non-word character /c\wt/ c$t cat \d digit /\d\d\d/ 123, abc123def a1b2c3 \D non-digit /\D\D\D/ some text 123ab456 modifiers A backslash can be used to "escape" any reserved characters /c.t/ - matches c.t and also cat, cot, cut /c\.t/ - matches c.t and nothing else Custom character patterns can be constructed using square brackets /c[aou]t/ - matches cat, cot, or cut, but not cet or cit a hyphen can be used to specify a range /c[a-fu-z]t/ - matches cat, cbt, cct, or cut, cvt, czt but not cit or cot /[0-9a-fA-F]/ - matches a hexadecimal character
8 a caret after the [ indicates negation /c[^aou]t/ - matches cet, cit, but not cat, cot, or cut /c[aou^ei]t/ - can't mix - caret must be at the beginning - if not, it's treated like a caret quantity modifiers Pattern Quantity Modifiers Matches Pattern True False * 0 or more times /ca*t/ ct, cat, caaaat cabat + 1 or more times /ca+t/ cat, caaaat ct? 0 or 1 times /ca?t/ ct, cat caaaat {n} Exactly n times /ca{3}t/ caaat {n,m} Between n and m times inclusively) ct, cat, caaaat /ca{1,3}t/ cat, caat, caaat ct, caaaat {n,} At least n times /ca{2,}t/ caat, caaaaat ct, cat parens Parenthesis have 2 purposes: Grouping Remembering Parenthesis for grouping or /\d?\d?\d?-?\d\d\d-\d\d\d\d/ /\d{3}?-?\d\d\d-\d\d\d\d/ /\d\d\d-)?\d\d\d-\d\d\d\d/ /\d{3}-)?\d{3}-\d{4}/
9 Parenthesis for remembering $phone = "The phone number is "; preg_match'/\d{3}-)?\d{3})-\d{4})/', $phone, $parts); print_r$parts); [0] => [1] => [2] => 555 [3] => 1212 ) $phone = "The phone number is "; preg_match'/\d{3}-)?\d{3})-\d{4})/', $phone, $parts); print_r$parts); [0] => [1] => 513- [2] => 555 [3] => 1212 ) /\d{3})?-?\d{3})-\d{4})/ - allows for or /\d{3})-)?\d{3})-\d{4})/ [0] => [1] => 513- [2] => 513 [3] => 555 [4] => 1212 ) A?: following an open paren causes the paren to be used for grouping but not remembering /?:\d{3})-)?\d{3})-\d{4})/ [0] => [1] => 513 [2] => 555 [3] => 1212 )
10 Rememberd patterns can also be referenced using \1, \2, \3, etc. /.).)\2\1/ Would match - abba, toot, otto, dood Would not match - abab abaa, abbb trailing options Trailing options Various modifiers can be added after the trailing slash i - ignore case /[0-9a-fA-F]/ - hexadecimal character /[0-9a-f]/i - same functions Regular Expression Functions Below are the function used with regular expressions: preg_match), preg_match_all) - match and extract) a pattern or all patterns from a string. preg_replace) - replace substrings that match a pattern with another substring. preg_split) - split a string based on a pattern. preg_grep) - find all elements of an array that match a pattern. preg_match preg_match preg_match) is used to match a single pattern in a string Stands for Perl-style Regular Expression Matching preg_matchpattern, string [, matches]) Returns 1 if the pattern matched, 0 if not. preg_match example
11 preg_match $ssn = ' '; if preg_match'/\d{3})-\d{2})-\d{4})/', $ssn, $parts)) { print_r$parts); } else { print "SSN not valid."; } [0] => [1] => 123 [2] => 45 [3] => 6789 ) preg_match_all preg_match_all preg_match_all) is used to match all occurrences of a pattern in a string preg_match_allpattern, string, matches [,order]) Returns the number of matches preg_match_all example preg_match_all $ssn = ' and '; preg_match_all'/\d{3})-\d{2})-\d{4})/', $ssn, $matches); print_r$matches); [0] => [0] => [1] => [1] => [0] => 123 [1] => 987 [2] => [0] => 45 [1] => 65 [3] => [0] => 6789 [1] => 4321 PREG_SET_ORDER preg_match_all $ssn = ' and '; preg_match_all'/\d{3})-\d{2})-\d{4})/', $ssn, $matches, PREG_SET_ORDER); print_r$matches); [0] => [0] => [1] => 123 [2] => 45 [3] => 6789 [1] => [0] => [1] => 987 [2] => 65 [3] => 4321 preg_replace
12 preg_replace preg_replace) is used replace strings based on a pattern preg_replacepattern, replacement, string [,limit]) Returns the replaced string preg_replace example preg_replace $html = 'Do <b>not</b> press the button.'; $text = preg_replace'/<[^>]+>/', '!', $html); print $text; Do!not! press the button. backreferences preg_replace $1, $2, etc. hold references to "remembered" items $names = 'Kent Covert, Tim Kingman, John Moose, Dirk Tepe'; $rnames = preg_replace'/\w+)\s\w+),/', "$2 $1,", $names); print $rnames; Covert Kent, Kingman Tim, Moose John, Tepe Dirk execute modifier preg_replace adding the e modifier after the pattern will cause the replacement string to be treated as PHP code with the result used as the replacement $headline = 'this is the big story'; $new = preg_replace'/\b\w)/e', "strtoupper$1)", $headline); print $new; This Is The Big Story arrays
13 preg_replace any or all of the first 3 arguments can be an array preg_replacepattern, replacement, string [,limit]) preg_split preg_split preg_split) is used split strings based on a pattern preg_splitpattern, string [,limit [,flags]]) Returns an array of the split items preg_split example preg_split $html = 'Do <b>not</b> press the <u>button</u>.'; $items = preg_split'/<[^>]+>/', $html); print_r$items); [0] => Do [1] => not [2] => press the [3] => button [4] =>. ) preg_split $html = 'Do <b>not</b> press the <u>button</u>.'; $items = preg_split'/\s*<[^>]+>\s*/', $html); print_r$items); [0] => Do [1] => not [2] => press the [3] => button [4] =>. ) preg_split flags
14 preg_split 2 flags can be used to modify the results of preg_split) PREG_SPLIT_NO_EMPTY - Doesn't return empty "chunks" PREG_SPLIT_DELIM_CAPTURE - returns separators as well as the separated items preg_grep preg_grep preg_grep) is used return elements from an array that match a pattern preg_greppattern, array) Returns an array of the matched items $textfiles = preg_grep'/\.txt$/', $filenames); preg_split example Questions? Homework #6
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 informationC How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.
C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features
More informationITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University
ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs
More informationServer-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Server-side Web Development (I3302) Semester: 1 Academic Year: 2017/2018 Credits: 4 (50 hours) Dr Antoun Yaacoub 2 Regular expressions
More informationWEBD 236 Web Information Systems Programming
WEBD 236 Web Information Systems Programming Week 8 Copyright 2013-2017 Todd Whittaker and Scott Sharkey (sharkesc@franklin.edu) Agenda This week s expected outcomes This week s topics This week s homework
More informationRegular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)
Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in
More informationWEB APPLICATION ENGINEERING II
WEB APPLICATION ENGINEERING II Lecture #4 Umar Ibrahim Enesi Objectives Gain understanding on: Form structure Form Handling Form Validation with Filters and Pattern matching Redirection Sticky form 06-Nov-16
More informationPIC 40A. Lecture 19: PHP Form handling, session variables and regular expressions. Copyright 2011 Jukka Virtanen UCLA 1 05/25/12
PIC 40A Lecture 19: PHP Form handling, session variables and regular expressions 05/25/12 Copyright 2011 Jukka Virtanen UCLA 1 How does a browser communicate with a program on a server? By submitting an
More informationThis page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl.
NAME DESCRIPTION perlrequick - Perl regular expressions quick start Perl version 5.16.2 documentation - perlrequick This page covers the very basics of understanding, creating and using regular expressions
More informationNote: Sections of this document are stolen right out of the official PHP manual:
Programming in PHP X52.9224 Spring 2005 Instructor : David Mintz http://davidmintz.org/php_course/ Session 3 Outline Form input validation, string manipulation and regular expressions;
More informationRegular Expressions. Todd Kelley CST8207 Todd Kelley 1
Regular Expressions Todd Kelley kelleyt@algonquincollege.com CST8207 Todd Kelley 1 POSIX character classes Some Regular Expression gotchas Regular Expression Resources Assignment 3 on Regular Expressions
More informationLanguage 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 informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationIntroduction. Server-side Techniques. Introduction. 2 modes in the PHP processor:
Introduction Server-side Techniques PHP Hypertext Processor A very popular server side language on web Code embedded directly into HTML documents http://hk2.php.net/downloads.php Features Free, open source
More informationVARIABLES AND CONSTANTS
UNIT 3 Structure VARIABLES AND CONSTANTS Variables and Constants 3.0 Introduction 3.1 Objectives 3.2 Character Set 3.3 Identifiers and Keywords 3.3.1 Rules for Forming Identifiers 3.3.2 Keywords 3.4 Data
More informationLecture 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 informationAWK - PRETTY PRINTING
AWK - PRETTY PRINTING http://www.tutorialspoint.com/awk/awk_pretty_printing.htm Copyright tutorialspoint.com So far we have used AWK's print and printf functions to display data on standard output. But
More informationInstructor s Notes Web Data Management PHP Sequential Processing Syntax. Web Data Management PHP Sequential Processing Syntax
Instructor s Web Data Management PHP Sequential Processing Syntax Web Data Management 152-155 PHP Sequential Processing Syntax Quick Links & Text References PHP tags in HTML Pages Comments Pages 48 49
More informationPHP 7.1 and SQL 5.7. Section Subject Page
One PHP Introduction 2 PHP: Hypertext Preprocessor 3 Some of its main uses 4 Two PHP Structure 5 Basic Structure of PHP 6 PHP Version etc 15 Use of Echo 17 Concatenating Echo 19 Use of Echo with Escape
More informationWho This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book. Source Code
Contents Introduction Who This Book Is For What This Book Covers How This Book Is Structured What You Need to Use This Book Conventions Source Code Errata p2p.wrox.com xxi xxi xxii xxii xxiii xxiii xxiv
More informationNumber Systems, Scalar Types, and Input and Output
Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point
More informationURLs 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 informationLanguage Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */
Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,
More informationUNIT - 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 informationWEBD 236 Web Information Systems Programming
WEBD 236 Web Information Systems Programming Week 5 Copyright 2013-2017 Todd Whittaker and Scott Sharkey (sharkesc@franklin.edu) Agenda This week s expected outcomes This week s topics This week s homework
More informationCS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code
CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output
More informationSTREAM EDITOR - REGULAR EXPRESSIONS
STREAM EDITOR - REGULAR EXPRESSIONS http://www.tutorialspoint.com/sed/sed_regular_expressions.htm Copyright tutorialspoint.com It is the regular expressions that make SED powerful and efficient. A number
More informationIDM 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 informationStrings are actually 'objects' Strings
Strings are actually 'objects' Strings What is an object?! An object is a concept that we can encapsulate data along with the functions that might need to access or manipulate that data. What is an object?!
More information"Hello" " This " + "is String " + "concatenation"
Strings About Strings Strings are objects, but there is a special syntax for writing String literals: "Hello" Strings, unlike most other objects, have a defined operation (as opposed to a method): " This
More informationRegex, Sed, Awk. Arindam Fadikar. December 12, 2017
Regex, Sed, Awk Arindam Fadikar December 12, 2017 Why Regex Lots of text data. twitter data (social network data) government records web scrapping many more... Regex Regular Expressions or regex or regexp
More informationDECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.
DECLARATIONS Character Set, Keywords, Identifiers, Constants, Variables Character Set C uses the uppercase letters A to Z. C uses the lowercase letters a to z. C uses digits 0 to 9. C uses certain Special
More informationUnit 4. Input/Output Functions
Unit 4 Input/Output Functions Introduction to Input/Output Input refers to accepting data while output refers to presenting data. Normally the data is accepted from keyboard and is outputted onto the screen.
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationPaolo Santinelli Sistemi e Reti. Regular expressions. Regular expressions aim to facilitate the solution of text manipulation problems
aim to facilitate the solution of text manipulation problems are symbolic notations used to identify patterns in text; are supported by many command line tools; are supported by most programming languages;
More informationUser Commands sed ( 1 )
NAME sed stream editor SYNOPSIS /usr/bin/sed [-n] script [file...] /usr/bin/sed [-n] [-e script]... [-f script_file]... [file...] /usr/xpg4/bin/sed [-n] script [file...] /usr/xpg4/bin/sed [-n] [-e script]...
More informationC++ Basics. Lecture 2 COP 3014 Spring January 8, 2018
C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing
More informationPattern Matching. An Introduction to File Globs and Regular Expressions
Pattern Matching An Introduction to File Globs and Regular Expressions Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your disadvantage, there are two different forms of patterns
More informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
More informationGabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming
1 Literal Constants Definition A literal or a literal constant is a value, such as a number, character or string, which may be assigned to a variable or a constant. It may also be used directly as a function
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationPattern Matching. An Introduction to File Globs and Regular Expressions. Adapted from Practical Unix and Programming Hunter College
Pattern Matching An Introduction to File Globs and Regular Expressions Adapted from Practical Unix and Programming Hunter College Copyright 2006 2009 Stewart Weiss The danger that lies ahead Much to your
More information211: Computer Architecture Summer 2016
211: Computer Architecture Summer 2016 Liu Liu Topic: C Programming Data Representation I/O: - (example) cprintf.c Memory: - memory address - stack / heap / constant space - basic data layout Pointer:
More informationChapter 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 informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationCopyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 18 I/O in C Standard C Library I/O commands are not included as part of the C language. Instead, they are part of the Standard C Library. A collection of functions and macros that must be implemented
More informationJava Basic Datatypees
Basic Datatypees Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in the memory. Based on the data type of a variable,
More informationProgramming in C++ 4. The lexical basis of C++
Programming in C++ 4. The lexical basis of C++! Characters and tokens! Permissible characters! Comments & white spaces! Identifiers! Keywords! Constants! Operators! Summary 1 Characters and tokens A C++
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationpsed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...]
NAME SYNOPSIS DESCRIPTION OPTIONS psed - a stream editor psed [-an] script [file...] psed [-an] [-e script] [-f script-file] [file...] s2p [-an] [-e script] [-f script-file] A stream editor reads the input
More informationCopyright 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 informationDaMPL. Language Reference Manual. Henrique Grando
DaMPL Language Reference Manual Bernardo Abreu Felipe Rocha Henrique Grando Hugo Sousa bd2440 flt2107 hp2409 ha2398 Contents 1. Getting Started... 4 2. Syntax Notations... 4 3. Lexical Conventions... 4
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationMuntaser Abulafi Yacoub Sabatin Omar Qaraeen. C Data Types
Programming Fundamentals for Engineers 0702113 5. Basic Data Types Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 2 C Data Types Variable definition C has a concept of 'data types' which are used to define
More informationINTRODUCTION 1 AND REVIEW
INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.
More informationFundamentals of Programming
Fundamentals of Programming Lecture 4 Input & Output Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline printf scanf putchar getchar getch getche Input and Output in
More informationC mini reference. 5 Binary numbers 12
C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char
More informationCST242 Strings and Characters Page 1
CST242 Strings and Characters Page 1 1 2 3 4 5 6 Strings, Characters and Regular Expressions CST242 char and String Variables A char is a Java data type (a primitive numeric) that uses two bytes (16 bits)
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi CE 43 - Fall 97 Lecture 4 Input and Output Department of Computer Engineering Outline printf
More information1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters
University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Review: Basic I/O in C Allowing Input from the Keyboard, Output to the Monitor
More informationMACHINE LEVEL REPRESENTATION OF DATA
MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationPHP. Interactive Web Systems
PHP Interactive Web Systems 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
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationML 4 A Lexer for OCaml s Type System
ML 4 A Lexer for OCaml s Type System CS 421 Fall 2017 Revision 1.0 Assigned October 26, 2017 Due November 2, 2017 Extension November 4, 2017 1 Change Log 1.0 Initial Release. 2 Overview To complete this
More informationStrings, characters and character literals
Strings, characters and character literals Internally, computers only manipulate bits of data; every item of data input can be represented as a number encoded in base 2. However, when it comes to processing
More informationRegular Expressions Explained
Found at: http://publish.ez.no/article/articleprint/11/ Regular Expressions Explained Author: Jan Borsodi Publishing date: 30.10.2000 18:02 This article will give you an introduction to the world of regular
More informationPrinciples of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore
(Refer Slide Time: 00:20) Principles of Compiler Design Prof. Y. N. Srikant Department of Computer Science and Automation Indian Institute of Science, Bangalore Lecture - 4 Lexical Analysis-Part-3 Welcome
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationPYTHON- AN INNOVATION
PYTHON- AN INNOVATION As per CBSE curriculum Class 11 Chapter- 2 By- Neha Tyagi PGT (CS) KV 5 Jaipur(II Shift) Jaipur Region Python Introduction In order to provide an input, process it and to receive
More informationfpp: Fortran preprocessor March 9, 2009
fpp: Fortran preprocessor March 9, 2009 1 Name fpp the Fortran language preprocessor for the NAG Fortran compiler. 2 Usage fpp [option]... [input-file [output-file]] 3 Description fpp is the preprocessor
More informationTCL - STRINGS. Boolean value can be represented as 1, yes or true for true and 0, no, or false for false.
http://www.tutorialspoint.com/tcl-tk/tcl_strings.htm TCL - STRINGS Copyright tutorialspoint.com The primitive data-type of Tcl is string and often we can find quotes on Tcl as string only language. These
More informationTHE FUNDAMENTAL DATA TYPES
THE FUNDAMENTAL DATA TYPES Declarations, Expressions, and Assignments Variables and constants are the objects that a prog. manipulates. All variables must be declared before they can be used. #include
More informationBabu Madhav Institute of Information Technology, UTU 2015
Five years Integrated M.Sc.(IT)(Semester 5) Question Bank 060010502:Programming in Python Unit-1:Introduction To Python Q-1 Answer the following Questions in short. 1. Which operator is used for slicing?
More informationUsing Lex or Flex. Prof. James L. Frankel Harvard University
Using Lex or Flex Prof. James L. Frankel Harvard University Version of 1:07 PM 26-Sep-2016 Copyright 2016, 2015 James L. Frankel. All rights reserved. Lex Regular Expressions (1 of 4) Special characters
More informationExercise: Using Numbers
Exercise: Using Numbers Problem: You are a spy going into an evil party to find the super-secret code phrase (made up of letters and spaces), which you will immediately send via text message to your team
More informationIntroduction to Regular Expressions Version 1.3. Tom Sgouros
Introduction to Regular Expressions Version 1.3 Tom Sgouros June 29, 2001 2 Contents 1 Beginning Regular Expresions 5 1.1 The Simple Version........................ 6 1.2 Difficult Characters........................
More informationPerl and Python ESA 2007/2008. Eelco Schatborn 27 September 2007
Perl and Python ESA 2007/2008 Eelco Schatborn eelco@os3.nl 27 September 2007 ESA: Perl Vandaag: 1. Perl introduction 2. Basic Perl: types, variables, statements,... 3. Object Oriented Perl 4. Documentation
More informationData Types and Variables in C language
Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are
More informationPHP 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 informationRUBY VARIABLES, CONSTANTS AND LITERALS
RUBY VARIABLES, CONSTANTS AND LITERALS http://www.tutorialspoint.com/ruby/ruby_variables.htm Copyright tutorialspoint.com Variables are the memory locations which hold any data to be used by any program.
More information.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..
.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. A Simple Program. simple.c: Basics of C /* CPE 101 Fall 2008 */ /* Alex Dekhtyar */ /* A simple program */ /* This is a comment!
More informationHere's an example of how the method works on the string "My text" with a start value of 3 and a length value of 2:
CS 1251 Page 1 Friday Friday, October 31, 2014 10:36 AM Finding patterns in text A smaller string inside of a larger one is called a substring. You have already learned how to make substrings in the spreadsheet
More informationC 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 informationPHP 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 informationThe Warhol Language Reference Manual
The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming
More informationWeb 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 informationFundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University
Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More informationPHP INTERVIEW QUESTION-ANSWERS
1. What is PHP? PHP (recursive acronym for PHP: Hypertext Preprocessor) is the most widely used open source scripting language, majorly used for web-development and application development and can be embedded
More informationEssentials for Scientific Computing: Stream editing with sed and awk
Essentials for Scientific Computing: Stream editing with sed and awk Ershaad Ahamed TUE-CMS, JNCASR May 2012 1 Stream Editing sed and awk are stream processing commands. What this means is that they are
More informationPrinceton University COS 333: Advanced Programming Techniques A Subset of PHP
Princeton University COS 333: Advanced Programming Techniques A Subset of PHP Program Structure -----------------------------------------------------------------------------------
More informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationProgramming for Engineers Introduction to C
Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationCS 230 Programming Languages
CS 230 Programming Languages 09 / 20 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Continue Regular expressions Matching string basics =~ (matches) m/ / (this is the format of match
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More information3 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 informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More information