SlideShare ist ein Scribd-Unternehmen logo
1 von 26
PHP 2 MDST 3559:  DataestheticsProf. Alvarado02/17/2011
Business VPN?
Review PHP Variables, Data Types, Functions See Chapters 2 through 5 of Programming PHP Text Earlier we saw the text handled as a tree (CSS, jQuery) Tuesday we treated the text as an array, a simple linear sequence,
Overview Today we will go back over the basics of PHP  To provide a slightly different angle on the subject To help clarify some concepts for those new to programming To help clarify the “PHP way” for those with experience Then we will cover two new topics Regular Expressions Creating your own functions
PHP as a language PHP is a programming langague (of course), but it has analogies to natural language as well There are parallels to the basic structures of human languages Which makes sense:  Programming languages are designed to mediate between human and machine language
What are some elements of natural language?
Some Elements of Natural Language Words Meanings Sentences Something is said of something else Parts of speech: nouns, verbs, prepositions Heart of language as language, beyond mere signs Paragraphs
PHP has all of these things
Values are Meanings Values are pieces of data Languages are all about doing things with data Data comes in types Types include strings and numbers Also Boolean values (true/false) Values are expressed literally and signified like so: “Hello, World!” 5 true These are the meanings of the language
Variables are Nouns Variables are words that can have meaning $POTUS = “Obama”; The President of the U.S. is Obama. Like the difference between person and office  They are like nouns that refer to things  Things being values ... They are always prefixed by $ and are case sensitive
(Arrays) Arrays are admittedly weird But they can be thought of as words that stand for collections, e.g. The Pittsburgh Steelers The UVA student body These phrases imply a structure Albeit much more complicated than arrays But not much: consider rosters ...
Functions are Verbs Functions are like verbs $food = food_shop($me,$money,$humger_level) Like verbs, they may require arguments and imply a result Verbs are action words Consider transitive versus intransitive They are not prefixed by $ They are not case sensitive They are followed by parentheses
Functions Verbs have implicit arguments and effects Subjects, objects, indirect objects, are like arguments Intransitive verbs are like functions that don’t take an argument Or, it is implicit (the subject) Functions like verbs imply actions that produce effects Person A: He ran for office. Person B: And ... ?
Expressions Expressions are like phrases that combine nouns and verbs 5 (5 + 10) / 36 “Tina” . “ is my cat”; file($url) $foo All expressions result in a value 5 0.4166666 ... Tina is my cat [the array of the file] [whatever $foo was last set to]
Statements Statements are like sentences.   They combine one or more expressions. $my_cat = “Tina”; $x = 2+2; They say something about something My Cat is Tina. $foois 2+2 (is 5) The verb “to be” is an assignment operator ... They are always punctuated by a semi-colon
Operators Expressions and statements are built out of words by combining them with grammatical words, such as prepositions and conjunctions Iam in the house. I own a catanda dog. Operators are like the grammatical words They don’t have meanings, they have functions They don’t reference values (i.e. data), they do things with values
Operators Arithmetic Addition, subtraction, division, multiplication, etc. String Concatenation Assignment X is Y Logical Is X Y? Is X related to Y in some  specified way?
Structures Structures, or control structures, are like stories or narrative patterns Built-in functions control conditions and iteration Repetition and branching
Conditions if / elseif/ else if ($x == ‘foo’) { 	// do something } elseif ($x == ‘bar’) { 	// do something else  } else {   	// do something else }
Iteration foreach() while()
Summary Values are like meanings Variables are like nouns Functions are like verbs Operators are like grammatical words These are combined to form expressions and statements Statements are structured in stories, or algorithms with control structures
Exercise Create directory for today Copy rex.php into it Let’s revisit the program and use control structures to format the text Use foreach() to loop through the file Use IF statements to grab what we want Format the text with tags
Two new functions preg_match($pattern, $string)  Two arguments A regular expression pattern (between slashes “/.../”) A string to apply the expression to preg_replace($pattern,$replacement,$string) Three arguments A regular expression A something to replace the matched string with A string to apply the expression to
Regular Expressions . = any character + = one or more * = 0 or more ^ = beginning of the string $ = end of the string [A-Za-z] = character set of all letters () = something to be replaced
Assignment Grab the Oedipux text  Trim the leading and trailing HTML tags Reformat each line using either DIV or P elements Create an appropriate CSS stylesheet for the text

Weitere ähnliche Inhalte

Was ist angesagt?

Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
Mayank Jain
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
Nikhil Deswal
 
24042020_normalization 1.pdf
24042020_normalization 1.pdf24042020_normalization 1.pdf
24042020_normalization 1.pdf
Shivani139202
 

Was ist angesagt? (18)

Prolog Programming Language
Prolog Programming  LanguageProlog Programming  Language
Prolog Programming Language
 
Introduction to prolog
Introduction to prologIntroduction to prolog
Introduction to prolog
 
10 logic+programming+with+prolog
10 logic+programming+with+prolog10 logic+programming+with+prolog
10 logic+programming+with+prolog
 
Enhanced E-R diagram
Enhanced E-R diagramEnhanced E-R diagram
Enhanced E-R diagram
 
Cardinality and participation constraints
Cardinality and participation constraintsCardinality and participation constraints
Cardinality and participation constraints
 
Functional dependency
Functional dependencyFunctional dependency
Functional dependency
 
Artificial intelligence Prolog Language
Artificial intelligence Prolog LanguageArtificial intelligence Prolog Language
Artificial intelligence Prolog Language
 
Chaps 1-3-ai-prolog
Chaps 1-3-ai-prologChaps 1-3-ai-prolog
Chaps 1-3-ai-prolog
 
Normalization
NormalizationNormalization
Normalization
 
Prolog basics
Prolog basicsProlog basics
Prolog basics
 
24042020_normalization 1.pdf
24042020_normalization 1.pdf24042020_normalization 1.pdf
24042020_normalization 1.pdf
 
Lesson 1 function as model
Lesson 1 function as modelLesson 1 function as model
Lesson 1 function as model
 
Prolog 01
Prolog 01Prolog 01
Prolog 01
 
Ics1019 ics5003
Ics1019 ics5003Ics1019 ics5003
Ics1019 ics5003
 
Introduction to Prolog
Introduction to PrologIntroduction to Prolog
Introduction to Prolog
 
Prolog
PrologProlog
Prolog
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
prolog ppt
prolog pptprolog ppt
prolog ppt
 

Andere mochten auch

Mdst 3559-01-27-data-journalism-studio
Mdst 3559-01-27-data-journalism-studioMdst 3559-01-27-data-journalism-studio
Mdst 3559-01-27-data-journalism-studio
Rafael Alvarado
 
Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2
Rafael Alvarado
 
Mdst3559 2011-05-03-final-day
Mdst3559 2011-05-03-final-dayMdst3559 2011-05-03-final-day
Mdst3559 2011-05-03-final-day
Rafael Alvarado
 
UVA MDST 3073 Texts and Models-2012-09-11
UVA MDST 3073 Texts and Models-2012-09-11UVA MDST 3073 Texts and Models-2012-09-11
UVA MDST 3073 Texts and Models-2012-09-11
Rafael Alvarado
 
Mdst 3559-04-05-networks-and-graphs
Mdst 3559-04-05-networks-and-graphsMdst 3559-04-05-networks-and-graphs
Mdst 3559-04-05-networks-and-graphs
Rafael Alvarado
 

Andere mochten auch (8)

Mdst 3559-02-01-html
Mdst 3559-02-01-htmlMdst 3559-02-01-html
Mdst 3559-02-01-html
 
MDST 3703 F10 Studio 11
MDST 3703 F10 Studio 11MDST 3703 F10 Studio 11
MDST 3703 F10 Studio 11
 
Mdst 3559-01-27-data-journalism-studio
Mdst 3559-01-27-data-journalism-studioMdst 3559-01-27-data-journalism-studio
Mdst 3559-01-27-data-journalism-studio
 
Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2
 
Mdst3559 2011-05-03-final-day
Mdst3559 2011-05-03-final-dayMdst3559 2011-05-03-final-day
Mdst3559 2011-05-03-final-day
 
UVA MDST 3073 Texts and Models-2012-09-11
UVA MDST 3073 Texts and Models-2012-09-11UVA MDST 3073 Texts and Models-2012-09-11
UVA MDST 3073 Texts and Models-2012-09-11
 
Mdst 3559-04-05-networks-and-graphs
Mdst 3559-04-05-networks-and-graphsMdst 3559-04-05-networks-and-graphs
Mdst 3559-04-05-networks-and-graphs
 
MDST 3703 F10 Seminar 1
MDST 3703 F10 Seminar 1MDST 3703 F10 Seminar 1
MDST 3703 F10 Seminar 1
 

Ähnlich wie Mdst 3559-02-17-php2

Mdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databasesMdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databases
Rafael Alvarado
 
Mind map esl 502
Mind map esl 502Mind map esl 502
Mind map esl 502
k1hinze
 
Introduction to Distributional Semantics
Introduction to Distributional SemanticsIntroduction to Distributional Semantics
Introduction to Distributional Semantics
Andre Freitas
 
Chart during reading strategies
Chart during reading strategiesChart during reading strategies
Chart during reading strategies
SECCIONDEINGLES
 

Ähnlich wie Mdst 3559-02-17-php2 (20)

Systemic Functional Grammar
Systemic Functional Grammar Systemic Functional Grammar
Systemic Functional Grammar
 
Textmining
TextminingTextmining
Textmining
 
Mdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databasesMdst3705 2013-02-05-databases
Mdst3705 2013-02-05-databases
 
Syntax 334 lecture 3
Syntax 334 lecture 3Syntax 334 lecture 3
Syntax 334 lecture 3
 
Mind map esl 502
Mind map esl 502Mind map esl 502
Mind map esl 502
 
Possible Word Representation
Possible Word RepresentationPossible Word Representation
Possible Word Representation
 
Syntax
SyntaxSyntax
Syntax
 
unit -3 part 1.ppt
unit -3 part 1.pptunit -3 part 1.ppt
unit -3 part 1.ppt
 
NLP
NLPNLP
NLP
 
Introduction to Distributional Semantics
Introduction to Distributional SemanticsIntroduction to Distributional Semantics
Introduction to Distributional Semantics
 
Php
PhpPhp
Php
 
Chart during reading strategies
Chart during reading strategiesChart during reading strategies
Chart during reading strategies
 
Beginners Guide on PHP Programming
Beginners Guide on PHP ProgrammingBeginners Guide on PHP Programming
Beginners Guide on PHP Programming
 
Representation of syntax, semantics and Predicate logics
Representation of syntax, semantics and Predicate logicsRepresentation of syntax, semantics and Predicate logics
Representation of syntax, semantics and Predicate logics
 
An Intuitive Natural Language Understanding System
An Intuitive Natural Language Understanding SystemAn Intuitive Natural Language Understanding System
An Intuitive Natural Language Understanding System
 
Lexical functional grammar (lfg).pptx
Lexical functional grammar (lfg).pptxLexical functional grammar (lfg).pptx
Lexical functional grammar (lfg).pptx
 
Syntax
SyntaxSyntax
Syntax
 
Nouns (sustantivos)
Nouns (sustantivos)Nouns (sustantivos)
Nouns (sustantivos)
 
Knowledge Extraction
Knowledge ExtractionKnowledge Extraction
Knowledge Extraction
 
Unit-4-Knowledge-representation.pdf
Unit-4-Knowledge-representation.pdfUnit-4-Knowledge-representation.pdf
Unit-4-Knowledge-representation.pdf
 

Mehr von Rafael Alvarado

Mdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collectionsMdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collections
Rafael Alvarado
 
Mdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-historyMdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-history
Rafael Alvarado
 
Mdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertextMdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertext
Rafael Alvarado
 
Mdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-htmlMdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-html
Rafael Alvarado
 
Mdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-modelsMdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-models
Rafael Alvarado
 
Mdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsMdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signals
Rafael Alvarado
 
Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2
Rafael Alvarado
 
Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2
Rafael Alvarado
 
Mdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-worldMdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-world
Rafael Alvarado
 
UVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 IntroductionUVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 Introduction
Rafael Alvarado
 
MDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to VisualizationMDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to Visualization
Rafael Alvarado
 
Mdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genreMdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genre
Rafael Alvarado
 
Mdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-dataMdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-data
Rafael Alvarado
 
Mdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-dataMdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-data
Rafael Alvarado
 
Mdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxisMdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxis
Rafael Alvarado
 
Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3
Rafael Alvarado
 
Mdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-languageMdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-language
Rafael Alvarado
 
Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2
Rafael Alvarado
 
Mdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introductionMdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introduction
Rafael Alvarado
 

Mehr von Rafael Alvarado (20)

Mdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collectionsMdst3703 2013-10-08-thematic-research-collections
Mdst3703 2013-10-08-thematic-research-collections
 
Mdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-historyMdst3703 2013-10-01-hypertext-and-history
Mdst3703 2013-10-01-hypertext-and-history
 
Mdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertextMdst3703 2013-09-24-hypertext
Mdst3703 2013-09-24-hypertext
 
Presentation1
Presentation1Presentation1
Presentation1
 
Mdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-htmlMdst3703 2013-09-12-semantic-html
Mdst3703 2013-09-12-semantic-html
 
Mdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-modelsMdst3703 2013-09-17-text-models
Mdst3703 2013-09-17-text-models
 
Mdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signalsMdst3703 2013-09-10-textual-signals
Mdst3703 2013-09-10-textual-signals
 
Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2Mdst3703 2013-09-05-studio2
Mdst3703 2013-09-05-studio2
 
Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2Mdst3703 2013-09-03-plato2
Mdst3703 2013-09-03-plato2
 
Mdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-worldMdst3703 2013-08-29-hello-world
Mdst3703 2013-08-29-hello-world
 
UVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 IntroductionUVA MDST 3703 2013 08-27 Introduction
UVA MDST 3703 2013 08-27 Introduction
 
MDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to VisualizationMDST 3705 2012-03-05 Databases to Visualization
MDST 3705 2012-03-05 Databases to Visualization
 
Mdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genreMdst3705 2013-02-26-db-as-genre
Mdst3705 2013-02-26-db-as-genre
 
Mdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-dataMdst3705 2013-02-19-text-into-data
Mdst3705 2013-02-19-text-into-data
 
Mdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-dataMdst3705 2013-02-12-finding-data
Mdst3705 2013-02-12-finding-data
 
Mdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxisMdst3705 2013-01-29-praxis
Mdst3705 2013-01-29-praxis
 
Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3Mdst3705 2013-01-31-php3
Mdst3705 2013-01-31-php3
 
Mdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-languageMdst3705 2012-01-22-code-as-language
Mdst3705 2012-01-22-code-as-language
 
Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2Mdst3705 2013-01-24-php2
Mdst3705 2013-01-24-php2
 
Mdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introductionMdst3705 2012-01-15-introduction
Mdst3705 2012-01-15-introduction
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Mdst 3559-02-17-php2

  • 1. PHP 2 MDST 3559: DataestheticsProf. Alvarado02/17/2011
  • 3. Review PHP Variables, Data Types, Functions See Chapters 2 through 5 of Programming PHP Text Earlier we saw the text handled as a tree (CSS, jQuery) Tuesday we treated the text as an array, a simple linear sequence,
  • 4. Overview Today we will go back over the basics of PHP To provide a slightly different angle on the subject To help clarify some concepts for those new to programming To help clarify the “PHP way” for those with experience Then we will cover two new topics Regular Expressions Creating your own functions
  • 5. PHP as a language PHP is a programming langague (of course), but it has analogies to natural language as well There are parallels to the basic structures of human languages Which makes sense: Programming languages are designed to mediate between human and machine language
  • 6. What are some elements of natural language?
  • 7.
  • 8. Some Elements of Natural Language Words Meanings Sentences Something is said of something else Parts of speech: nouns, verbs, prepositions Heart of language as language, beyond mere signs Paragraphs
  • 9. PHP has all of these things
  • 10. Values are Meanings Values are pieces of data Languages are all about doing things with data Data comes in types Types include strings and numbers Also Boolean values (true/false) Values are expressed literally and signified like so: “Hello, World!” 5 true These are the meanings of the language
  • 11. Variables are Nouns Variables are words that can have meaning $POTUS = “Obama”; The President of the U.S. is Obama. Like the difference between person and office They are like nouns that refer to things Things being values ... They are always prefixed by $ and are case sensitive
  • 12. (Arrays) Arrays are admittedly weird But they can be thought of as words that stand for collections, e.g. The Pittsburgh Steelers The UVA student body These phrases imply a structure Albeit much more complicated than arrays But not much: consider rosters ...
  • 13. Functions are Verbs Functions are like verbs $food = food_shop($me,$money,$humger_level) Like verbs, they may require arguments and imply a result Verbs are action words Consider transitive versus intransitive They are not prefixed by $ They are not case sensitive They are followed by parentheses
  • 14. Functions Verbs have implicit arguments and effects Subjects, objects, indirect objects, are like arguments Intransitive verbs are like functions that don’t take an argument Or, it is implicit (the subject) Functions like verbs imply actions that produce effects Person A: He ran for office. Person B: And ... ?
  • 15. Expressions Expressions are like phrases that combine nouns and verbs 5 (5 + 10) / 36 “Tina” . “ is my cat”; file($url) $foo All expressions result in a value 5 0.4166666 ... Tina is my cat [the array of the file] [whatever $foo was last set to]
  • 16. Statements Statements are like sentences. They combine one or more expressions. $my_cat = “Tina”; $x = 2+2; They say something about something My Cat is Tina. $foois 2+2 (is 5) The verb “to be” is an assignment operator ... They are always punctuated by a semi-colon
  • 17. Operators Expressions and statements are built out of words by combining them with grammatical words, such as prepositions and conjunctions Iam in the house. I own a catanda dog. Operators are like the grammatical words They don’t have meanings, they have functions They don’t reference values (i.e. data), they do things with values
  • 18. Operators Arithmetic Addition, subtraction, division, multiplication, etc. String Concatenation Assignment X is Y Logical Is X Y? Is X related to Y in some specified way?
  • 19. Structures Structures, or control structures, are like stories or narrative patterns Built-in functions control conditions and iteration Repetition and branching
  • 20. Conditions if / elseif/ else if ($x == ‘foo’) { // do something } elseif ($x == ‘bar’) { // do something else } else { // do something else }
  • 22. Summary Values are like meanings Variables are like nouns Functions are like verbs Operators are like grammatical words These are combined to form expressions and statements Statements are structured in stories, or algorithms with control structures
  • 23. Exercise Create directory for today Copy rex.php into it Let’s revisit the program and use control structures to format the text Use foreach() to loop through the file Use IF statements to grab what we want Format the text with tags
  • 24. Two new functions preg_match($pattern, $string) Two arguments A regular expression pattern (between slashes “/.../”) A string to apply the expression to preg_replace($pattern,$replacement,$string) Three arguments A regular expression A something to replace the matched string with A string to apply the expression to
  • 25. Regular Expressions . = any character + = one or more * = 0 or more ^ = beginning of the string $ = end of the string [A-Za-z] = character set of all letters () = something to be replaced
  • 26. Assignment Grab the Oedipux text Trim the leading and trailing HTML tags Reformat each line using either DIV or P elements Create an appropriate CSS stylesheet for the text