Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
PHP... osnove

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 14.12.2005 15:48    Post subject: PHP... osnove Add user to your forum ignore list Reply with quote

muči me nešto konkretno, možda i glupo al eto...
hoću da se na jednoj stranici, ako je uvjet ispunjen, prikaže stranica s nekim html kodom a ako uvjet nije ispunjen da samo nešto ispiše ali još uvijek u istom layoutu.

u biti pitanje glasi kako iz php-a ispisati veću količinu html koda a ne redak po redak echo, echo...
išlo bi ovako nekako
if (nešto) {
echo "<div><p>adsfhgjad"sdfad" ..... .... " ----- s tim da tu ide jedno čudo koda Smile
}
else{
echo "<div><p> poruka </p><div>"
}

layout je definiran izvan <php> taga... može li to ovako ili ako ne kako da to izvedem?

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 14.12.2005 16:36    Post subject: Add user to your forum ignore list Reply with quote

mozes ovako recimo...

Code:
<?php

    if (nesto) {

?>

tvoj html kod

<?php

    } else {

?>

neki drugi html kod

<?php

    }

?>

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 14.12.2005 16:39    Post subject: Add user to your forum ignore list Reply with quote

nisam znala da to tako funcionira... sad bi trebalo biti piece of cake
hvala che Smile

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 14.12.2005 17:19    Post subject: Add user to your forum ignore list Reply with quote

E kad sam ja učio PHP, pročitao sam o ovome što je Che paste-ao i mislio "ma neee!!" Shocked ali sam to brzo usvojio i naravno, ne može se normalan HTML radit bez toga Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 14.12.2005 17:24    Post subject: Add user to your forum ignore list Reply with quote

mda nisam ni ja to znao kad sam krenuo programirati...s tim da nisam znao ni da ako koristis jednostruke navodnike ne moras escapeati normalne navodnike...jebote kolko je slasheva to bilo Embarassed

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
sinke



Joined: 02 Oct 2005
Posts: 257
Location: Zagreb

PostPosted: 14.12.2005 21:05    Post subject: Add user to your forum ignore list Reply with quote

Code:
<?php

if (uvjet_za_nesto) {
    include ("nesto.php");
} else {
    include ("nesto_sasvim_drugo.php");
}

?>


S tim da u nesto.php i nesto_sasvim_drugo.php, staviš svoj html.
Kod je puno čišći, a samim tim i pregledniji. A možda ćeš html kod koji je u nesto.php ili nesto_sasvim_dugo.php, trebati još negdje pa ćeš ga imati samo na jednom mjestu..

_________________
THE SHTANZIG | Web Do's & Don'ts
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 14.12.2005 21:16    Post subject: Add user to your forum ignore list Reply with quote

Za templejtove je najpreglednije (osim inkluzije):
Code:
<?php if(nesto): ?>

tvoj html kod

<?php else: ?>

neki drugi html kod

<?php endif; ?>

Che-ov primjer, remixed.

Zatucenjaci odbijaju koristit ovu sintaksu ali za ovakve blokove je super. Sa short tagovima postaje:
Code:
<? if(nesto): ?>
tvoj html kod
<? else: ?>
neki drugi html kod
<? endif; ?>
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 14.12.2005 21:44    Post subject: Add user to your forum ignore list Reply with quote

eh da, zasto se preporuca <?php a ne <? ?
kad sam svoj prvi tutorial o PHP-u procitala tamo je pisalo da je <?php bolje, e sad ja nisam zapamtila zasto... a mozda nije ni pisalo.

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 14.12.2005 21:45    Post subject: Add user to your forum ignore list Reply with quote

zbog kompatibilnosti...moguce je da je u php.ini-u disableana opcija short opening tag ili tak nes

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
sinisa.kusic



Joined: 26 Jul 2005
Posts: 728
Location: Rijeka

PostPosted: 14.12.2005 21:51    Post subject: Add user to your forum ignore list Reply with quote

<?php opening tag osigurava kompatibilnost sa starijim verzijama php. I što je retro rekao short tags mogu i najčešće jesu disejblani u php.ini-u.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
sinke



Joined: 02 Oct 2005
Posts: 257
Location: Zagreb

PostPosted: 15.12.2005 01:00    Post subject: Add user to your forum ignore list Reply with quote

feelfree wrote:
... short tags mogu i najčešće jesu disejblani u php.ini-u.

Nisam nikad naletio na disableane, a mislim da su po defaultu omogućeni u php.ini

Držim da je jedan od glavnih razloga zašto koristiti <?php taj što XML također koristi <? pa može doći do "problema".

Što se tiče kompatibilnosti unatrag, mislim da je nepotrebno zamarati se time Twisted Evil

_________________
THE SHTANZIG | Web Do's & Don'ts
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 15.12.2005 02:06    Post subject: Add user to your forum ignore list Reply with quote

Mastersinke spasio si stvar Wink
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 15.12.2005 08:51    Post subject: Add user to your forum ignore list Reply with quote

retro_one wrote:
mda nisam ni ja to znao kad sam krenuo programirati...s tim da nisam znao ni da ako koristis jednostruke navodnike ne moras escapeati normalne navodnike...jebote kolko je slasheva to bilo Embarassed


misliš da nisam probala sa tim slashevima Cool ali jok, nije išlo ni tako
ovo što mi je che otkrio me skroz oduševilo i odjednom mi je php puno puno draži

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 15.12.2005 12:34    Post subject: Add user to your forum ignore list Reply with quote

novo pitanje Smile

kako je najpametnije prenositi vrijednosti varijabli između stranica, je li nužno koristiti cookie?
probala sam ono sa session register al javlja greške...

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 15.12.2005 12:59    Post subject: Add user to your forum ignore list Reply with quote

jesi stavila start_session() prije nego registriranja session varijabli?

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 15.12.2005 13:12    Post subject: Add user to your forum ignore list Reply with quote

jesam..
evo i s cookiem mi javlja grešku:
Cannot modify header information - headers already sent by (output started at...

u ostalim topicima na sličnu temu spominje se mijenjanje php.ini filea... treba li to mijenjati da bi cookie i session radili?

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 15.12.2005 13:19    Post subject: Add user to your forum ignore list Reply with quote

ne mozes definirati headere nakon sto si outputala nes (echo, print, bilo kakav html)

rjesenje su ti output buffer funkcije pa ih prouci malo

http://www.php.net/manual/en/ref.outcontrol.php

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 15.12.2005 14:35    Post subject: Add user to your forum ignore list Reply with quote

Da, headeri, postavljanje cookija i session_start (koji svi efektivno rade istu stvar) ovise o tome da nisi do te točke u code-u outputala ništa

session je najbolje startat u početku, imaš i INI direktivu auto-start
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jojo



Joined: 27 Jan 2005
Posts: 1591
Location: insula aurea

PostPosted: 15.12.2005 14:45    Post subject: Add user to your forum ignore list Reply with quote

proradilo je, samo mi je trebalo malo da shvatim kad se stvari 'ispuštaju' i tako to
u biti treba samo stavit session na samom početku koda pa nema problema
thx again

_________________
deviant / malomorgen / videoholik / cimer fraj
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group