SlideShare a Scribd company logo
1 of 22
Kurs PHP
Programski jezik za dinamicke web stranice
Predavanje 2
- Sta je PHP
- Osnovna sintaksa PHP
- Dev okruzenje za razvoj PHP aplikacija
- Sta su XAMPP, MAMP, WAMP, LAMP
- Instalacija lokalnog servera
- Hello world from PHP
- Client server model & HTTP protocol - osnove
<?php echo ‘Recap’ ?>
- Varijabla (promjenjiva/variable) je jedinica date ili informacije u
racunarskom programu koja moze promijeniti vrijednost u toku
izvrsavanja programa.
<?php echo ‘Varijable u PHP’ ?>
# PRIMJER KODA:
<?php
# Inicijalizacija dvije varijable
$firstName = ‘Nermin’
$lastName = ‘Sehic’
# Primjer promjene vrijednosti vec inicijalizirane varijable
$firstName = ‘John’
$lastName = ‘Doe’
<?php echo ‘Varijable u PHP’ ?>
- Varijable se identifikuju uz pomoc znaka ’$’
- U praksi se najcesce koristi camel case naming convention ($firstSecond)
- Duga imena nisu pozeljna zbog preglednosti koda
- Prvi karakter poslije ’$’ je uvijek slovo (‘$123’ nije validno ime)
- Imena varijabli treba da budu dekriptivna te da reflektuju svrhu
njihovog koristenja.
- Varijable popt $a, $b se preporucuju samo kao index counteri u
petljama.
<?php echo ‘Varijable u PHP’ ?>
- Skinuti starter template sa Github-a
URL: https://github.com/newPrimitives/php-kurs/blob/master/lecture2/example1_starterTemplate.php
- Incijalizirati varijable $link1, $link2, $link3
- Ispisati varijable u za to naznacena mjesta
- Promijeniti vrijednost varijable title
<?php echo ‘Vjezba 1’ ?>
- Artimetricke operacije
- Assignment operatori
- Znakovi poredjenja
- Increment/decrement operatori
- Logicki operatori
- String operatori
<?php echo ‘Osnovne operacije u PHP’ ?>
Primjer 1 – Lista operacija u PHP
https://github.com/newPrimitives/php-kurs/blob/master/lecture2/operators.php
<?php echo ‘Primjer’ ?>
- 3 nacina za pisanje komentara
- Single line komentar
- Multiline komentar
- Inline komentar
<?php echo ‘Komentari u PHP’ ?>
# PRIMJER KODA:
<?php
# Sintaksa za single line komentar
echo ‘Hello World’
echo ‘Hello World’ // sintaksa za inline komentar
/**
* Sintaksa za multi line
* komentar
*/
echo ’Hello world;
<?php echo ‘Komentari u PHP’ ?>
- Konstatama, za razliku od varijabli, nije moguce promijeniti vrijednost
nakon inicijalizacije
- Koristi se UPPER_CASE sintaksa za imenovanje da bi se razlikovale od
varijabli
- Postoje user defined I reserved konstante (reserved konstante koriste
odredjene klase I funkcije unutar PHP )
<?php echo ‘Konstante u PHP’ ?>
Primjer 2 – Deklarisanje konstanti
https://github.com/newPrimitives/php-kurs/blob/master/lecture2/constants.php
<?php echo ‘Primjer’ ?>
Primjer 3 – Magic konstante
http://php.net/manual/en/language.constants.predefined.php
<?php echo ‘Primjer’ ?>
- U programiranju, keyword string predstavlja skup karaktera koji cine
neku rijec ili tekst. Svaki od karaktera u stringu ima posebnu numericku
oznaku u tzv. ASCII tabeli.
- $word = ‘String example’
<?php echo ‘Stringovi u PHP’ ?>
- Kombinovanje stringova
- Funkcije za trim i length stringa
- Pretrage stringova
- Zamjena karaktera u stringu
<?php echo ‘Operacije sa stringovima’ ?>
Primjer 4 – Operacije sa stringovima
https://github.com/newPrimitives/php-kurs/blob/master/lecture2/stringOperations.php
<?php echo ‘Primjer’ ?>
- Koristit rjesenje vjezbe 1 kao starter template za vjezbu 2
URL: https://github.com/newPrimitives/php-kurs/blob/master/lecture2/example1_final.php
- Koristeci built in funkciju substr() ukloniti http i/ili www iz imena linka te
ga takvog ispisati u title dio href-a.
<?php echo ‘Vjezba 2’ ?>
<a href=“#LINK SA HTTP://WWW" target="_blank"> <!-- Ime linka bez HTTP://WWW --> </a>
Git 101
- Git je version control system cija se primjena najcesce pronalazi u
razvoju software-a, mobilnih aplikacija I web stranica
- Napravljen je izvorno za potrebe Linux kernel-a 2005 godine
- Postoji nekoliko servisa/kompanija koji nude git kao svoj proizvod.
- Neke od najpopularnijih su Github, Bitbucket, Gitlab
<?php echo ‘Git flow’?>
- Varijable u PHP
- Osnovne operacije u PHP
- Komentari U PHP
- Konstante u PHP
- Userdefined & Magic konstante
- Stringovi u PHP
- Operacije sa stringovima
- Git - 101
<?php echo ‘To sum up’?>
<?php echo ‘Pitanja’?>

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

PHP za pocetnike - predavanje 2

  • 1. Kurs PHP Programski jezik za dinamicke web stranice Predavanje 2
  • 2. - Sta je PHP - Osnovna sintaksa PHP - Dev okruzenje za razvoj PHP aplikacija - Sta su XAMPP, MAMP, WAMP, LAMP - Instalacija lokalnog servera - Hello world from PHP - Client server model & HTTP protocol - osnove <?php echo ‘Recap’ ?>
  • 3. - Varijabla (promjenjiva/variable) je jedinica date ili informacije u racunarskom programu koja moze promijeniti vrijednost u toku izvrsavanja programa. <?php echo ‘Varijable u PHP’ ?>
  • 4. # PRIMJER KODA: <?php # Inicijalizacija dvije varijable $firstName = ‘Nermin’ $lastName = ‘Sehic’ # Primjer promjene vrijednosti vec inicijalizirane varijable $firstName = ‘John’ $lastName = ‘Doe’ <?php echo ‘Varijable u PHP’ ?>
  • 5. - Varijable se identifikuju uz pomoc znaka ’$’ - U praksi se najcesce koristi camel case naming convention ($firstSecond) - Duga imena nisu pozeljna zbog preglednosti koda - Prvi karakter poslije ’$’ je uvijek slovo (‘$123’ nije validno ime) - Imena varijabli treba da budu dekriptivna te da reflektuju svrhu njihovog koristenja. - Varijable popt $a, $b se preporucuju samo kao index counteri u petljama. <?php echo ‘Varijable u PHP’ ?>
  • 6. - Skinuti starter template sa Github-a URL: https://github.com/newPrimitives/php-kurs/blob/master/lecture2/example1_starterTemplate.php - Incijalizirati varijable $link1, $link2, $link3 - Ispisati varijable u za to naznacena mjesta - Promijeniti vrijednost varijable title <?php echo ‘Vjezba 1’ ?>
  • 7. - Artimetricke operacije - Assignment operatori - Znakovi poredjenja - Increment/decrement operatori - Logicki operatori - String operatori <?php echo ‘Osnovne operacije u PHP’ ?>
  • 8. Primjer 1 – Lista operacija u PHP https://github.com/newPrimitives/php-kurs/blob/master/lecture2/operators.php <?php echo ‘Primjer’ ?>
  • 9. - 3 nacina za pisanje komentara - Single line komentar - Multiline komentar - Inline komentar <?php echo ‘Komentari u PHP’ ?>
  • 10. # PRIMJER KODA: <?php # Sintaksa za single line komentar echo ‘Hello World’ echo ‘Hello World’ // sintaksa za inline komentar /** * Sintaksa za multi line * komentar */ echo ’Hello world; <?php echo ‘Komentari u PHP’ ?>
  • 11. - Konstatama, za razliku od varijabli, nije moguce promijeniti vrijednost nakon inicijalizacije - Koristi se UPPER_CASE sintaksa za imenovanje da bi se razlikovale od varijabli - Postoje user defined I reserved konstante (reserved konstante koriste odredjene klase I funkcije unutar PHP ) <?php echo ‘Konstante u PHP’ ?>
  • 12. Primjer 2 – Deklarisanje konstanti https://github.com/newPrimitives/php-kurs/blob/master/lecture2/constants.php <?php echo ‘Primjer’ ?>
  • 13. Primjer 3 – Magic konstante http://php.net/manual/en/language.constants.predefined.php <?php echo ‘Primjer’ ?>
  • 14. - U programiranju, keyword string predstavlja skup karaktera koji cine neku rijec ili tekst. Svaki od karaktera u stringu ima posebnu numericku oznaku u tzv. ASCII tabeli. - $word = ‘String example’ <?php echo ‘Stringovi u PHP’ ?>
  • 15. - Kombinovanje stringova - Funkcije za trim i length stringa - Pretrage stringova - Zamjena karaktera u stringu <?php echo ‘Operacije sa stringovima’ ?>
  • 16. Primjer 4 – Operacije sa stringovima https://github.com/newPrimitives/php-kurs/blob/master/lecture2/stringOperations.php <?php echo ‘Primjer’ ?>
  • 17. - Koristit rjesenje vjezbe 1 kao starter template za vjezbu 2 URL: https://github.com/newPrimitives/php-kurs/blob/master/lecture2/example1_final.php - Koristeci built in funkciju substr() ukloniti http i/ili www iz imena linka te ga takvog ispisati u title dio href-a. <?php echo ‘Vjezba 2’ ?> <a href=“#LINK SA HTTP://WWW" target="_blank"> <!-- Ime linka bez HTTP://WWW --> </a>
  • 19. - Git je version control system cija se primjena najcesce pronalazi u razvoju software-a, mobilnih aplikacija I web stranica - Napravljen je izvorno za potrebe Linux kernel-a 2005 godine - Postoji nekoliko servisa/kompanija koji nude git kao svoj proizvod. - Neke od najpopularnijih su Github, Bitbucket, Gitlab <?php echo ‘Git flow’?>
  • 20.
  • 21. - Varijable u PHP - Osnovne operacije u PHP - Komentari U PHP - Konstante u PHP - Userdefined & Magic konstante - Stringovi u PHP - Operacije sa stringovima - Git - 101 <?php echo ‘To sum up’?>