SlideShare uma empresa Scribd logo
1 de 19
Kurs PHP
Programski jezik za dinamicke web stranice
Predavanje 3
- 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 ‘Recap’ ?>
- Operatori poredjenja (compassion operators) sluze za poredjenje 2 ili
vise vrijednosti
- Poredjenja varijabli omogucavaju aplikaciji da donosi odluke
(compassion expression)
<?php echo ‘Poredjenje varijabli’ ?>
Primjer 1 – Poredjenje varijabli
https://github.com/newPrimitives/php-kurs/blob/master/lecture4/comparisonOperators.php
<?php echo ‘Primjer’ ?>
- Nizovi (array) su grupa podataka koji predstavljaju jednu cjelinu. Niz ima
svoje ime, tip I velicinu. Niz se stastoji od clanova niza koji imaju svoju
vrijednost I mjesto u nizu.
<?php echo ‘Nizovi’ ?>
- Elementu se pristupa koristeci key
- Tip key-a moze biti samo integer
- Element niza moze biti bilo koji tip varijable
<?php echo ‘Numericki nizovi’ ?>
<?php echo ‘Numericki nizovi’ ?>
# PRIMJER NUMERICKOG NIZA:
[‘VOLVO’, ‘BMW’, ’AUDI’, ‘KIA’]
[0] [1] [2] [3]
# Inicijalizacija Niza
$cars = array(‘Volvo’, ‘Bmw’, ‘Audi’, ‘Kia’);
$cars = [‘Volvo, ‘Bmw’, ‘Audi’, ‘Kia’];
# Pristup elementu niza
echo $cars[0];
- Razlika izmedju numeric I associative niza je u tipu key-a koji se koristi za
pristup elementima niza.
- Associative niz za key koristi string umjesto integer-a
<?php echo ‘Associative nizovi’ ?>
# PRIMJER ASSOCIATIVE NIZA:
$person[‘firstName’] = ‘Nermin’;
$person[‘age’] = 23;
$echo $person[‘firstName’];
- Skinuti starter template sa Github-a
URL: https://github.com/newPrimitives/php-kurs/blob/master/lecture3/example1_starterTemplate.php
- Inicijalizirati associative niz $person sa zadatim atributima.
- Ispisati array koristeci prethodno definisane key-eve uz pomoc echo ili
print_f funkcije
- Za url slike, kopirati bilo koji link sa Google-a ili Facebook-a
<?php echo ‘Vjezba 1’ ?>
- Postoji nekoliko nacina sortiranja nizova
- Sortiranje po vrijednosti od veceg ka manjem elementu
- Sortiranje po key-u od veceg ka manjem key-u
- Sortiranje od manjeg ka vecem
<?php echo ‘Sortiranje nizova’ ?>
Primjer 2 – Sortiranje nizova
https://github.com/newPrimitives/php-kurs/blob/master/lecture3/arraySort.php
<?php echo ‘Primjer’ ?>
Primjer 3 – Brisanje iz niza
https://github.com/newPrimitives/php-kurs/blob/master/lecture3/removeArray.php
<?php echo ‘Primjer’ ?>
- Inicijalizirati numeric array sa 5 elemenata od kojih su svi integeri
razlicitih vrijednosti
- Pronaci najmanju vrijednost u nizu te je nakon toga izbrisati i ispisati
preostale elemente koristeci echo ili print_f
<?php echo ‘Vjezba 2’ ?>
- Koristeci built in funkciju array_diff, moguce je jako brzo saznati koji
elementi se ne nalaze u oba niza, tacnije njihovu razliku. Return funkcije
array_diff je novi niz kojim se moze dalje manpiulisati.
<?php echo ‘Razlika izmedju nizova’ ?>
# PRIMJER array_diff FUNKCIJE:
array_diff($array1, $array2);
- Koristeci built in funkciju array_merge, moguce je spojiti dva niza I sve
njihove elemente u novi niz (unija nizova).
<?php echo ‘Spajanje nizova’ ?>
# PRIMJER array_merge FUNKCIJE:
array_merge($array1, $array2);
- Multidimenzionalni niz je niz koji kao svoje elemente sadrzi druge
nizove. Za dvodimenzionalni niz pristupanje elementu se vrsi koristeci
dva key-a. Analogija se prati ukoliko se broj nizova povecava.
<?php echo ‘Multidimenzionalni nizovi’ ?>
<?php echo ‘Multidimenzionalni nizovi’ ?>
# PRIMJER MULTIDIMENZIONALNOG NIZA:
$cars = array (
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
- Poredjenja varijabli
- Sta su nizovi
- Vrste nizova
- Sintaksa nizova
- Sortiranje nizova
- Brisanje iz nizova
- Unija I razlika izmedju nizova
- Multidimenzionalni nizovi
<?php echo ‘To sum up’?>
<?php echo ‘Pitanja’?>

Mais conteúdo relacionado

Destaque

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
 

Destaque (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 3

  • 1. Kurs PHP Programski jezik za dinamicke web stranice Predavanje 3
  • 2. - 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 ‘Recap’ ?>
  • 3. - Operatori poredjenja (compassion operators) sluze za poredjenje 2 ili vise vrijednosti - Poredjenja varijabli omogucavaju aplikaciji da donosi odluke (compassion expression) <?php echo ‘Poredjenje varijabli’ ?>
  • 4. Primjer 1 – Poredjenje varijabli https://github.com/newPrimitives/php-kurs/blob/master/lecture4/comparisonOperators.php <?php echo ‘Primjer’ ?>
  • 5. - Nizovi (array) su grupa podataka koji predstavljaju jednu cjelinu. Niz ima svoje ime, tip I velicinu. Niz se stastoji od clanova niza koji imaju svoju vrijednost I mjesto u nizu. <?php echo ‘Nizovi’ ?>
  • 6. - Elementu se pristupa koristeci key - Tip key-a moze biti samo integer - Element niza moze biti bilo koji tip varijable <?php echo ‘Numericki nizovi’ ?>
  • 7. <?php echo ‘Numericki nizovi’ ?> # PRIMJER NUMERICKOG NIZA: [‘VOLVO’, ‘BMW’, ’AUDI’, ‘KIA’] [0] [1] [2] [3] # Inicijalizacija Niza $cars = array(‘Volvo’, ‘Bmw’, ‘Audi’, ‘Kia’); $cars = [‘Volvo, ‘Bmw’, ‘Audi’, ‘Kia’]; # Pristup elementu niza echo $cars[0];
  • 8. - Razlika izmedju numeric I associative niza je u tipu key-a koji se koristi za pristup elementima niza. - Associative niz za key koristi string umjesto integer-a <?php echo ‘Associative nizovi’ ?> # PRIMJER ASSOCIATIVE NIZA: $person[‘firstName’] = ‘Nermin’; $person[‘age’] = 23; $echo $person[‘firstName’];
  • 9. - Skinuti starter template sa Github-a URL: https://github.com/newPrimitives/php-kurs/blob/master/lecture3/example1_starterTemplate.php - Inicijalizirati associative niz $person sa zadatim atributima. - Ispisati array koristeci prethodno definisane key-eve uz pomoc echo ili print_f funkcije - Za url slike, kopirati bilo koji link sa Google-a ili Facebook-a <?php echo ‘Vjezba 1’ ?>
  • 10. - Postoji nekoliko nacina sortiranja nizova - Sortiranje po vrijednosti od veceg ka manjem elementu - Sortiranje po key-u od veceg ka manjem key-u - Sortiranje od manjeg ka vecem <?php echo ‘Sortiranje nizova’ ?>
  • 11. Primjer 2 – Sortiranje nizova https://github.com/newPrimitives/php-kurs/blob/master/lecture3/arraySort.php <?php echo ‘Primjer’ ?>
  • 12. Primjer 3 – Brisanje iz niza https://github.com/newPrimitives/php-kurs/blob/master/lecture3/removeArray.php <?php echo ‘Primjer’ ?>
  • 13. - Inicijalizirati numeric array sa 5 elemenata od kojih su svi integeri razlicitih vrijednosti - Pronaci najmanju vrijednost u nizu te je nakon toga izbrisati i ispisati preostale elemente koristeci echo ili print_f <?php echo ‘Vjezba 2’ ?>
  • 14. - Koristeci built in funkciju array_diff, moguce je jako brzo saznati koji elementi se ne nalaze u oba niza, tacnije njihovu razliku. Return funkcije array_diff je novi niz kojim se moze dalje manpiulisati. <?php echo ‘Razlika izmedju nizova’ ?> # PRIMJER array_diff FUNKCIJE: array_diff($array1, $array2);
  • 15. - Koristeci built in funkciju array_merge, moguce je spojiti dva niza I sve njihove elemente u novi niz (unija nizova). <?php echo ‘Spajanje nizova’ ?> # PRIMJER array_merge FUNKCIJE: array_merge($array1, $array2);
  • 16. - Multidimenzionalni niz je niz koji kao svoje elemente sadrzi druge nizove. Za dvodimenzionalni niz pristupanje elementu se vrsi koristeci dva key-a. Analogija se prati ukoliko se broj nizova povecava. <?php echo ‘Multidimenzionalni nizovi’ ?>
  • 17. <?php echo ‘Multidimenzionalni nizovi’ ?> # PRIMJER MULTIDIMENZIONALNOG NIZA: $cars = array ( array("Volvo",22,18), array("BMW",15,13), array("Saab",5,2), array("Land Rover",17,15) );
  • 18. - Poredjenja varijabli - Sta su nizovi - Vrste nizova - Sintaksa nizova - Sortiranje nizova - Brisanje iz nizova - Unija I razlika izmedju nizova - Multidimenzionalni nizovi <?php echo ‘To sum up’?>