SlideShare a Scribd company logo
PHP for HTML Gurus
Andrea Tarr
Tarr Consulting
J and Beyond 2012
Outline
• PHP Basics
• Explanation of
  actual code in
  templates &




                     Beyond 2012 • Andrea Tarr
                     PHP for HTML Gurus • J and
  layouts
• Changing code
  and seeing it in
  action
• Book give away
                                2
PHP Basics
• Get in and out of PHP with <?php ?>
• End each statement with a semi-colon
<?php
      $first_name = 'Andrea';




                                                  Beyond 2012 • Andrea Tarr
                                                  PHP for HTML Gurus • J and
      $last_name = 'Tarr';
?>

• Whitespace is irrelevant
<?php $first_name='Andrea';$last_name='Tarr';?>


• Omit any final ?> at the end of a file                     3
Comments
• Single line comments
// This is a single line comment
$language = 'PHP'; // End of line comment
// Multiple lines of single comments




                                            Beyond 2012 • Andrea Tarr
                                            PHP for HTML Gurus • J and
// can be done by repeating the slashes

• Multiple line comments
/* With this type of comment you can
start a comment on one line and end
it on an other line */
                                                       4
Variables
•   Used to store information that can change
•   Start with a $
•   Assign a value with =
•   Use single ('') or double ("") quotes for text




                                                      Beyond 2012 • Andrea Tarr
                                                      PHP for HTML Gurus • J and
• You need to assign a value before you can use the
  variable
• Use echo to display a value
• Use a dot (.) to join items together

$first_name = 'Andrea';
$last_name = 'Tarr';                                             5
echo $first_name . ' ' . $last_name;
$Variable Types
•   String Text: Andrea
•   Numbers: 42
•   Logical: True/False, 1/0
•   Array: An array is a list, either indexed or named




                                                         Beyond 2012 • Andrea Tarr
                                                         PHP for HTML Gurus • J and
    • [0]=>Sun, [1]=>Mon, [2]=>Tue, [3]=>Wed
    • Name=>Joomla, Version=>2.5,
    • You can nest arrays
• Object: We'll come back to Object shortly



                                                                    6
Functions()
• Functions perform an action
• You recognize a function by the ()
• You can pass information to the function in the ()
$full_name = '       Andrea             Tarr       ';
echo trim($full_name);




                                                        Beyond 2012 • Andrea Tarr
                                                        PHP for HTML Gurus • J and
• This results in Andrea Tarr

• You can pass a function to a function
echo strtoupper(trim($full_name);

• This results in ANDREA TARR                                      7
CONSTANTS
• Constants are assigned once and don't change
• No $
• Usually in ALL CAPS
define('SITENAME', 'My Site');




                                                 Beyond 2012 • Andrea Tarr
                                                 PHP for HTML Gurus • J and
echo SITENAME;




                                                            8
Objects
• Think of an object as a named array plus functions
• Properties are variables
• Functions are also called methods




                                                       Beyond 2012 • Andrea Tarr
                                                       PHP for HTML Gurus • J and
Examples:
• $item->title contains the title
• $item->introtext contains the intro text
• $params->get('show_modify_date')



                                                                  9
Classes
• Classes are the blueprints that are used to create
  objects
• You can use the classes directly without creating an
  object




                                                         Beyond 2012 • Andrea Tarr
                                                         PHP for HTML Gurus • J and
Examples:
• JText::_('COM_CONTENT_READ_MORE');
• JHtml::_('string.truncate', ($this->item->title),
  $params->get('readmore_limit'))


                                                               10
Making Decisions: if/else
• Example 1
if ($sum > 10) :
      // do something when greater than 10
else :
      // do something when 10 or less




                                              Beyond 2012 • Andrea Tarr
                                              PHP for HTML Gurus • J and
endif;

• Example 2
if ($errors) :
      // do something when there are errors
endif;
                                                    11
• You can also nest if statements
Comparison Operators




Don't use = to compare!




                          PHP for HTML Gurus • J and
12




                          Beyond 2012 • Andrea Tarr
One Line If Statement
• Normal way
if ($gender == 'M') :
     echo 'Man';
else :




                                           Beyond 2012 • Andrea Tarr
                                           PHP for HTML Gurus • J and
     echo 'Woman';
endif;

• One line version
echo ($gender == 'M') ? 'Man' : 'Woman';

                                                 13
Alternative Syntax
• Alternative Syntax used when mixing with HTML
if ($sum > 10) :
       // do something when greater than 10
else :
       // do something when 10 or less




                                                  Beyond 2012 • Andrea Tarr
                                                  PHP for HTML Gurus • J and
endif;

• Normal syntax with curly braces
if ($sum > 10) {
      // do something when greater than 10
} else {
      // do something when 10 or less                   14
}
Looping
• While
  • Repeats while a condition is true
• Do/While
  • Does it at least once then repeats while true
• For




                                                       Beyond 2012 • Andrea Tarr
                                                       PHP for HTML Gurus • J and
  • Loops a given number of times
• Foreach
  • Repeats the code for each element in an array or
    object
• Jumping out early
  • Continue
        • Jump to the next iteration
  • Break                                                    15
        • Jump out of the loop
Template index.php file
•   Template Parameters
•   Conditional Stylesheets
•   Conditional Positions
•   One Line If Statement




                              Beyond 2012 • Andrea Tarr
                              PHP for HTML Gurus • J and
                                    16
Template Parameters
$color = $this->params->get('templatecolor');

<link rel="stylesheet" href="<?php echo
$this->baseurl ?>/templates/<?php echo




                                                       Beyond 2012 • Andrea Tarr
                                                       PHP for HTML Gurus • J and
$this->template; ?>/css/<?php echo
 htmlspecialchars($color); ?>.css"
type="text/css" />

<link rel="stylesheet"
href="/localhost/jc/templates/beez_20/css/personal.c
ss" type="text/css" />                                       17
Conditional Stylesheets
<?php if ($this->direction == 'rtl') : ?>
 <link rel="stylesheet" href="<?php echo
 $this->baseurl ?>/templates/<?php echo
 $this->template; ?>/css/template_rtl.css"




                                             Beyond 2012 • Andrea Tarr
                                             PHP for HTML Gurus • J and
 type="text/css" />
<?php endif; ?>




                                                   18
Conditional Positions
<?php if ($this->countModules('position-12')): ?>
<div id="top">
 <jdoc:include type="modules" name="position-12" />
</div>




                                                      Beyond 2012 • Andrea Tarr
                                                      PHP for HTML Gurus • J and
<?php endif; ?>




                                                            19
One Line If Statement
$showRightColumn =
($this->countModules('position-3') OR
$this->countModules('position-6') OR
$this->countModules('position-8'));




                                                      Beyond 2012 • Andrea Tarr
                                                      PHP for HTML Gurus • J and
<div id="<?php echo
 $showRightColumn ? 'contentarea2' : 'contentarea';
?>">

If there are right modules: <div id="contentarea2">
If there aren't: <div id="contentarea">                     20
Module Layout
• Latest Articles
• mod_articles_latest/tmpl/default.php




                                         Beyond 2012 • Andrea Tarr
                                         PHP for HTML Gurus • J and
                                               21
Latest Articles




     PHP for HTML Gurus • J and
22




     Beyond 2012 • Andrea Tarr
Latest News default.php




     PHP for HTML Gurus • J and
23




     Beyond 2012 • Andrea Tarr
var_dump()




     PHP for HTML Gurus • J and
24




     Beyond 2012 • Andrea Tarr
Object $item




     PHP for HTML Gurus • J and
25




     Beyond 2012 • Andrea Tarr
Object $item




     PHP for HTML Gurus • J and
26




     Beyond 2012 • Andrea Tarr
Object $item – Page 2




     PHP for HTML Gurus • J and
27




     Beyond 2012 • Andrea Tarr
Object $item – Page 3




     PHP for HTML Gurus • J and
28




     Beyond 2012 • Andrea Tarr
Object $item – Page 4




     PHP for HTML Gurus • J and
29




     Beyond 2012 • Andrea Tarr
Object $item – Page 5




     PHP for HTML Gurus • J and
30




     Beyond 2012 • Andrea Tarr
Object $item – Page 6




     PHP for HTML Gurus • J and
31




     Beyond 2012 • Andrea Tarr
Add information




     PHP for HTML Gurus • J and
32




     Beyond 2012 • Andrea Tarr
List with intro text




     PHP for HTML Gurus • J and
33




     Beyond 2012 • Andrea Tarr
Questions?




     PHP for HTML Gurus • J and
34




     Beyond 2012 • Andrea Tarr
Book Give Away




     PHP for HTML Gurus • J and
35




     Beyond 2012 • Andrea Tarr
Ad

More Related Content

What's hot (12)

Regular expression unit2
Regular expression unit2Regular expression unit2
Regular expression unit2
smitha273566
 
OOP - Introduction to Inheritance
OOP - Introduction to InheritanceOOP - Introduction to Inheritance
OOP - Introduction to Inheritance
Mohammad Shaker
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
Jayfee Ramos
 
Java script
Java scriptJava script
Java script
Prarthan P
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
Hitesh-Java
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
LB Denker
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
Robby Firmansyah
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
Kumar
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
Dr. Ramkumar Lakshminarayanan
 
Ravi software faculty
Ravi software facultyRavi software faculty
Ravi software faculty
ravikumar4java
 
Os Borger
Os BorgerOs Borger
Os Borger
oscon2007
 
Regular expression unit2
Regular expression unit2Regular expression unit2
Regular expression unit2
smitha273566
 
OOP - Introduction to Inheritance
OOP - Introduction to InheritanceOOP - Introduction to Inheritance
OOP - Introduction to Inheritance
Mohammad Shaker
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
Smita B Kumar
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
Hitesh-Java
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
LB Denker
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
Kumar
 

Viewers also liked (7)

PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
Yuriy Krapivko
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with php
Joe Ferguson
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
Dhani Ahmad
 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
Ashish Chamoli
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHP
Sudheer Satyanarayana
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
Manish Bothra
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Jussi Pohjolainen
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with php
Joe Ferguson
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
Dhani Ahmad
 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
Ashish Chamoli
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHP
Sudheer Satyanarayana
 
Ad

Similar to PHP for HTML Gurus - J and Beyond 2012 (20)

Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code Reuse
Rayhan Chowdhury
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
Rob Knight
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
Lecture 6: Introduction to PHP and Mysql .pptx
Lecture 6:  Introduction to PHP and Mysql .pptxLecture 6:  Introduction to PHP and Mysql .pptx
Lecture 6: Introduction to PHP and Mysql .pptx
AOmaAli
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
Richard McIntyre
 
PHP 5.4 New Features
PHP 5.4 New FeaturesPHP 5.4 New Features
PHP 5.4 New Features
Haim Michael
 
PHP Variables & Comments 01
PHP Variables & Comments 01PHP Variables & Comments 01
PHP Variables & Comments 01
Spy Seat
 
TDD with PhpSpec
TDD with PhpSpecTDD with PhpSpec
TDD with PhpSpec
CiaranMcNulty
 
Synapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephp
SynapseindiaComplaints
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
Simon Jones
 
Introduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdfIntroduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdf
MacSila
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
Hermes Alves
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend Expressive
Milad Arabi
 
Lecture 9 - Intruduction to BOOTSTRAP.pptx
Lecture 9 - Intruduction to BOOTSTRAP.pptxLecture 9 - Intruduction to BOOTSTRAP.pptx
Lecture 9 - Intruduction to BOOTSTRAP.pptx
AOmaAli
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016
CiaranMcNulty
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
Welcome to hack
Welcome to hackWelcome to hack
Welcome to hack
Timothy Chandler
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.js
souridatta
 
DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014
David Wolfpaw
 
Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code Reuse
Rayhan Chowdhury
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
Rob Knight
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
Mohammed Mushtaq Ahmed
 
Lecture 6: Introduction to PHP and Mysql .pptx
Lecture 6:  Introduction to PHP and Mysql .pptxLecture 6:  Introduction to PHP and Mysql .pptx
Lecture 6: Introduction to PHP and Mysql .pptx
AOmaAli
 
PHP 5.4 New Features
PHP 5.4 New FeaturesPHP 5.4 New Features
PHP 5.4 New Features
Haim Michael
 
PHP Variables & Comments 01
PHP Variables & Comments 01PHP Variables & Comments 01
PHP Variables & Comments 01
Spy Seat
 
Synapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephp
SynapseindiaComplaints
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
Simon Jones
 
Introduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdfIntroduction to PHP_Slides by Lesley_Bonyo.pdf
Introduction to PHP_Slides by Lesley_Bonyo.pdf
MacSila
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
Hermes Alves
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend Expressive
Milad Arabi
 
Lecture 9 - Intruduction to BOOTSTRAP.pptx
Lecture 9 - Intruduction to BOOTSTRAP.pptxLecture 9 - Intruduction to BOOTSTRAP.pptx
Lecture 9 - Intruduction to BOOTSTRAP.pptx
AOmaAli
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016
CiaranMcNulty
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
Ahmed Swilam
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
GeorgePeterBanyard
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.js
souridatta
 
DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014
David Wolfpaw
 
Ad

More from Andrea Tarr (8)

Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013
Andrea Tarr
 
The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013
Andrea Tarr
 
LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS Preprocessor
Andrea Tarr
 
Bootstrap & Joomla UI
Bootstrap & Joomla UIBootstrap & Joomla UI
Bootstrap & Joomla UI
Andrea Tarr
 
Bootstrap for Extension Developers JWC 2012
Bootstrap for Extension Developers  JWC 2012Bootstrap for Extension Developers  JWC 2012
Bootstrap for Extension Developers JWC 2012
Andrea Tarr
 
Bootstrap Introduction
Bootstrap IntroductionBootstrap Introduction
Bootstrap Introduction
Andrea Tarr
 
Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012
Andrea Tarr
 
Choosing Great Joomla Extensions
Choosing Great Joomla ExtensionsChoosing Great Joomla Extensions
Choosing Great Joomla Extensions
Andrea Tarr
 
Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013
Andrea Tarr
 
The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013
Andrea Tarr
 
LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS Preprocessor
Andrea Tarr
 
Bootstrap & Joomla UI
Bootstrap & Joomla UIBootstrap & Joomla UI
Bootstrap & Joomla UI
Andrea Tarr
 
Bootstrap for Extension Developers JWC 2012
Bootstrap for Extension Developers  JWC 2012Bootstrap for Extension Developers  JWC 2012
Bootstrap for Extension Developers JWC 2012
Andrea Tarr
 
Bootstrap Introduction
Bootstrap IntroductionBootstrap Introduction
Bootstrap Introduction
Andrea Tarr
 
Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012
Andrea Tarr
 
Choosing Great Joomla Extensions
Choosing Great Joomla ExtensionsChoosing Great Joomla Extensions
Choosing Great Joomla Extensions
Andrea Tarr
 

Recently uploaded (20)

Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
Make GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI FactoryMake GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Vibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdfVibe Coding_ Develop a web application using AI (1).pdf
Vibe Coding_ Develop a web application using AI (1).pdf
Baiju Muthukadan
 
Bepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firmBepents tech services - a premier cybersecurity consulting firm
Bepents tech services - a premier cybersecurity consulting firm
Benard76
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...Canadian book publishing: Insights from the latest salary survey - Tech Forum...
Canadian book publishing: Insights from the latest salary survey - Tech Forum...
BookNet Canada
 
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Hybridize Functions: A Tool for Automatically Refactoring Imperative Deep Lea...
Raffi Khatchadourian
 
Make GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI FactoryMake GenAI investments go further with the Dell AI Factory
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent LasterAI 3-in-1: Agents, RAG, and Local Models - Brent Laster
AI 3-in-1: Agents, RAG, and Local Models - Brent Laster
All Things Open
 
AsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API DesignAsyncAPI v3 : Streamlining Event-Driven API Design
AsyncAPI v3 : Streamlining Event-Driven API Design
leonid54
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
TrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token ListingTrsLabs Consultants - DeFi, WEb3, Token Listing
TrsLabs Consultants - DeFi, WEb3, Token Listing
Trs Labs
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptxWebinar - Top 5 Backup Mistakes MSPs and Businesses Make   .pptx
Webinar - Top 5 Backup Mistakes MSPs and Businesses Make .pptx
MSP360
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 

PHP for HTML Gurus - J and Beyond 2012

  • 1. PHP for HTML Gurus Andrea Tarr Tarr Consulting J and Beyond 2012
  • 2. Outline • PHP Basics • Explanation of actual code in templates & Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and layouts • Changing code and seeing it in action • Book give away 2
  • 3. PHP Basics • Get in and out of PHP with <?php ?> • End each statement with a semi-colon <?php $first_name = 'Andrea'; Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and $last_name = 'Tarr'; ?> • Whitespace is irrelevant <?php $first_name='Andrea';$last_name='Tarr';?> • Omit any final ?> at the end of a file 3
  • 4. Comments • Single line comments // This is a single line comment $language = 'PHP'; // End of line comment // Multiple lines of single comments Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and // can be done by repeating the slashes • Multiple line comments /* With this type of comment you can start a comment on one line and end it on an other line */ 4
  • 5. Variables • Used to store information that can change • Start with a $ • Assign a value with = • Use single ('') or double ("") quotes for text Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • You need to assign a value before you can use the variable • Use echo to display a value • Use a dot (.) to join items together $first_name = 'Andrea'; $last_name = 'Tarr'; 5 echo $first_name . ' ' . $last_name;
  • 6. $Variable Types • String Text: Andrea • Numbers: 42 • Logical: True/False, 1/0 • Array: An array is a list, either indexed or named Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • [0]=>Sun, [1]=>Mon, [2]=>Tue, [3]=>Wed • Name=>Joomla, Version=>2.5, • You can nest arrays • Object: We'll come back to Object shortly 6
  • 7. Functions() • Functions perform an action • You recognize a function by the () • You can pass information to the function in the () $full_name = ' Andrea Tarr '; echo trim($full_name); Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • This results in Andrea Tarr • You can pass a function to a function echo strtoupper(trim($full_name); • This results in ANDREA TARR 7
  • 8. CONSTANTS • Constants are assigned once and don't change • No $ • Usually in ALL CAPS define('SITENAME', 'My Site'); Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and echo SITENAME; 8
  • 9. Objects • Think of an object as a named array plus functions • Properties are variables • Functions are also called methods Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and Examples: • $item->title contains the title • $item->introtext contains the intro text • $params->get('show_modify_date') 9
  • 10. Classes • Classes are the blueprints that are used to create objects • You can use the classes directly without creating an object Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and Examples: • JText::_('COM_CONTENT_READ_MORE'); • JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit')) 10
  • 11. Making Decisions: if/else • Example 1 if ($sum > 10) : // do something when greater than 10 else : // do something when 10 or less Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and endif; • Example 2 if ($errors) : // do something when there are errors endif; 11 • You can also nest if statements
  • 12. Comparison Operators Don't use = to compare! PHP for HTML Gurus • J and 12 Beyond 2012 • Andrea Tarr
  • 13. One Line If Statement • Normal way if ($gender == 'M') : echo 'Man'; else : Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and echo 'Woman'; endif; • One line version echo ($gender == 'M') ? 'Man' : 'Woman'; 13
  • 14. Alternative Syntax • Alternative Syntax used when mixing with HTML if ($sum > 10) : // do something when greater than 10 else : // do something when 10 or less Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and endif; • Normal syntax with curly braces if ($sum > 10) { // do something when greater than 10 } else { // do something when 10 or less 14 }
  • 15. Looping • While • Repeats while a condition is true • Do/While • Does it at least once then repeats while true • For Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • Loops a given number of times • Foreach • Repeats the code for each element in an array or object • Jumping out early • Continue • Jump to the next iteration • Break 15 • Jump out of the loop
  • 16. Template index.php file • Template Parameters • Conditional Stylesheets • Conditional Positions • One Line If Statement Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and 16
  • 17. Template Parameters $color = $this->params->get('templatecolor'); <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and $this->template; ?>/css/<?php echo htmlspecialchars($color); ?>.css" type="text/css" /> <link rel="stylesheet" href="/localhost/jc/templates/beez_20/css/personal.c ss" type="text/css" /> 17
  • 18. Conditional Stylesheets <?php if ($this->direction == 'rtl') : ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template_rtl.css" Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and type="text/css" /> <?php endif; ?> 18
  • 19. Conditional Positions <?php if ($this->countModules('position-12')): ?> <div id="top"> <jdoc:include type="modules" name="position-12" /> </div> Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and <?php endif; ?> 19
  • 20. One Line If Statement $showRightColumn = ($this->countModules('position-3') OR $this->countModules('position-6') OR $this->countModules('position-8')); Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and <div id="<?php echo $showRightColumn ? 'contentarea2' : 'contentarea'; ?>"> If there are right modules: <div id="contentarea2"> If there aren't: <div id="contentarea"> 20
  • 21. Module Layout • Latest Articles • mod_articles_latest/tmpl/default.php Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and 21
  • 22. Latest Articles PHP for HTML Gurus • J and 22 Beyond 2012 • Andrea Tarr
  • 23. Latest News default.php PHP for HTML Gurus • J and 23 Beyond 2012 • Andrea Tarr
  • 24. var_dump() PHP for HTML Gurus • J and 24 Beyond 2012 • Andrea Tarr
  • 25. Object $item PHP for HTML Gurus • J and 25 Beyond 2012 • Andrea Tarr
  • 26. Object $item PHP for HTML Gurus • J and 26 Beyond 2012 • Andrea Tarr
  • 27. Object $item – Page 2 PHP for HTML Gurus • J and 27 Beyond 2012 • Andrea Tarr
  • 28. Object $item – Page 3 PHP for HTML Gurus • J and 28 Beyond 2012 • Andrea Tarr
  • 29. Object $item – Page 4 PHP for HTML Gurus • J and 29 Beyond 2012 • Andrea Tarr
  • 30. Object $item – Page 5 PHP for HTML Gurus • J and 30 Beyond 2012 • Andrea Tarr
  • 31. Object $item – Page 6 PHP for HTML Gurus • J and 31 Beyond 2012 • Andrea Tarr
  • 32. Add information PHP for HTML Gurus • J and 32 Beyond 2012 • Andrea Tarr
  • 33. List with intro text PHP for HTML Gurus • J and 33 Beyond 2012 • Andrea Tarr
  • 34. Questions? PHP for HTML Gurus • J and 34 Beyond 2012 • Andrea Tarr
  • 35. Book Give Away PHP for HTML Gurus • J and 35 Beyond 2012 • Andrea Tarr

Editor's Notes

  • #2: Introduction to meIntro to the course. This isn&apos;t meant to teach you how to write PHP from scratch. It&apos;s meant to make you more comfortable around the php you come across in templates and layouts.Who can copy/paste PHP statements in templates and layouts? Who can make minor changes to PHP? Who can write PHP? Anyone here who is new to both HTML and PHP?
  • #3: I&apos;m going to start by going through the basics of how PHP works. This is going to go fairly fast and don&apos;t expect to remember all of it. It will make more sense when we start looking at the actual code, but it helps if you understand a bit of the basics first.So once we finish that, we will look at (what exactly are the files?)Then we&apos;ll try changing something in the code (adding a missing field, like the intro to something that is only title?) and see it working in actiion
  • #6: The nouns $color css files
  • #8: functions are the verb
  • #17: $this = JDocumentHTML
  • #24: This is the layout file that outputs the list of latest articles. This is the file that you would copy to your template to override with your changes
  • #25: $list is aAdd a var_dump to see what&apos;s there that we want to use