Website Development Prices

Search Blog

Wednesday, March 30, 2016

Prosledjivanje argumenata po referenci (Passing arguments by reference)

Kada se funkciji prosledjuje argument, podrazumevano se prosledjuje po vrednosti. To znaci da se u funkciju salje kopija podatka a ne sam podatak. 

Ako zelite da promenite originalnu vrednost koju ste prosledili u funkciju, na primer, ako zelite stringu koji je usao u funkciju dodate neki tekst:

Primer:

<?php

$string = "Ja volim ";

dodaj_tekst($string);
echo $string;

function dodaj_tekst($tekst)
{
$tekst .= "motore.";
}
?> 

Rezultat:

Monday, March 21, 2016

Simple website design and code-Part 3

In previous two articles we designed home page and we sliced it and now we are going to code it.


Step 1 - Setting up files and folders

You are supposed to have folder first-website. In that folder you have another folder images, with images from previous article and first-website - Copy.xcf file. 



Rename this file to first-website.xcf



Open this file in GIMP, we'll need to pick up fonts, colors... In your first-website folder add two files - index.html and style.css. Open the editor of your choice, press CTRL+N twice to create new files. 

Saturday, March 19, 2016

Simple website design and code-Part 2

Slicing the GIMP design (home page)





In the previous article we created home page and now we are going to slice it.

Step 1 - .xcf file

Make copy of your
.xcf file.



Step 2 - Header

We will stretch it out across the whole screen. We are going to take slice of header and repeat it across the screen again and again.

a) Open the copy of your
.xcf file - first-website - Copy.xcf. Remove all guides from document. Select Move Tool (M),



hover over guide (red line), click (green line) and move left to the ruler to remove vertical guides. If you have any horizontally guides, hover over them, click and move up to the ruler to remove them.

Definisanje podrazumevanih argumenata funkcije (Defining default arguments of function)

U prethodnom clanku videli smo kako mozemo da funkciji prosledimo podatke.

Primer:

<?php

ucim_php("Ja ucim PHP.");

function ucim_php($tekst)
{
echo $tekst, "<br />";

}

?>

Rezultat:

Ja ucim PHP.

Ako ovoj funkciji zaboravite da prosledite argument i pozovete je 

<?php

ucim_php();

function ucim_php($tekst)
{
     echo $tekst, "<br />";
}

?>

dobicete poruku o gresci

Friday, March 18, 2016

Simple website design and code-Part 1

We are going to design and code simple website. Part 1 will be GIMP design of home page, Part 2 Slicing GIMP design (home page) and Part 3 will be code.


Step 1 - What you need

  • GIMP
  • A code editor (Notepad++, Sublime Text 2 or 3, or any other)
  • Basic understanding of how HTML works, basic syntax and tags
  • Basic understanding of CSS, also you should understand how selectors work and be familiar with basic properties.
  • A browser Chrome, Firefox ...
Step 2 - What we are making

We will make a very simple home page, with four basic elements: header, content, sidebar and footer.

Tip: when you make some changes to the document, press CTRL+S to save document.
Step 3 - Let's start

Open up new GIMP document (CTRL+N), for example, 1100px by 1200px.



Save file, for example, first-website.xcf.

Tuesday, March 15, 2016

Prosledjivanje nizova u funkciju (Passing arrays in function)

Pored podataka koji predstavljaju obicne promenljive, u funkcije mozete da prosledite i nizove. 

Primer: kreiracemo funkciju stampaj_niz, koja stampa sadrzaj niza.

<?php

$motor[0] = "suzuki";
$motor[1] = "honda";
$motor[2] = "kawasaki";
$motor[3] = "yamaha";

stampaj_niz($motor);

function stampaj_niz($niz)
{
for ($indeks = 0; $indeks < count($niz); $indeks++) {
echo "Motor $indeks: ", $niz[$indeks], "<br />";
}

}

?>

Rezultat:

Monday, March 14, 2016

Prosledjivanje podataka funkcijama (Passing data to functions)

Funkciji mozete da prosledite podatke pomocu liste argumenata. To je lista naziva promenljivih, koji su odvojeni zarezima.

function ime_funkcije([lista_argumenta...])
{
[iskazi];
[return vracena_vrednost];

}

Primer: ako zelite da prilagodite navigacioni meni koji smo napravili u prethodnom clanku, na primer, zelite da dodate neki tekst i oznaku autorskih prava. To mozete da uradite tako sto cete u funkciju poslati te dve stavke. Ako bismo te dve stavke u telu funkcije oznacili kao $tekst i $autorska_prava, onda bi funkcija mogla da izgleda ovako:

Saturday, March 12, 2016

Kreiranje funkcije (Creating function)

Sintaksa za kreiranje funkcije:

function ime_funkcije([lista_argumenta...])
{
[iskazi];
[return vracena_vrednost];

}

Primer: na svim vasim web stranicama postoji navigacioni meni  sa hiperlinkovima koji se nalazi na dnu strane. Umesto da sav kod koji je potreban ubacujete na svaku web stranicu, mozete da napravite funkciju, koju mozete nazvati navigacioni_meni, da ona to radi umesto vas. Iskazi koji postoje u ovoj funkciji ce se izvrsiti u trenutku njenog poziva. Dodacemo echo iskaze koji salju HTML kod za navigacioni meni i hiperlinkove nazad do pretrazivaca. "&nbsp" u HTML kod ubacuje prazne karaktere da bi linkovi bili odvojeni.

Kako postaviti pozadinsku sliku sa iseckom slike (How to set background image with slice image)

Pitanje: kako postaviti pozadinsku sliku sa iseckom slike?

Resenje: svojstva background i background-repeat.

Primer:

HTML kod

<!DOCTYPE html>
<html>
<head>
<title>Pozadinska slika sa iseckom slike</title>

<meta charset="UTF-8"/>
<meta name="description" content="Description that search reads" />
<meta name="keywords" content="page keywords, keywords" />
<meta name="author" content="Marija Rikic">
<link rel="icon" type="image/png" href="images/favicon.jpg">
<link rel="stylesheet" type="text/css" href="style.css">
</head>

Friday, March 11, 2016

Upotreba operatora za rad sa nizovima (Using the operators to work with arrays)

Operatori za rad sa nizovima:



Primer: proveravamo da li dva niza imaju iste elemente.

<?php

$japan["suzuki"] = 15;  
$japan["honda"] = 19; 
$kina["shineray"] = 11; 
$kina["thumpstar"] = 17; 

echo "\$japan: ";
print_r($japan);
echo "<br />";
echo "\$kina: ";
print_r($kina);
echo "<br />";

$motori = $japan + $kina;
echo "\$motori: ";
print_r($motori);
echo "<br />";

if ($japan == $kina) {
echo "\$japan ima iste elemente kao \$kina<br />";
} else {
echo "\$japan nema iste elemente kao \$kina<br />";
}

?>