Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding > Coding Tutorials
You last visited: Today at 06:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



PHP Include statt Frames

Discussion on PHP Include statt Frames within the Coding Tutorials forum part of the General Coding category.

Reply
 
Old   #1


 
Milchschokolade's Avatar
 
elite*gold: 4
Join Date: Mar 2011
Posts: 135
Received Thanks: 10
PHP Include statt Frames

Ihr kennt sicherlich das Problem. Ihr habt z.B. ein News-"Addon" in der Sidebar & wollt dieses aktualisieren.
Nur bei jeder Datei einzelnt? Das wär zu aufwändig. Daher greifen einige zu Frames. Das Problem dabei: Suchmaschienen mögen Webseiten mit Frames nicht so gerne^^

PHP schafft da Abhilfe mit der include Funtion. Der grundsätzliche Syntax:
PHP Code:
<? include ("datei.php"); ?>
Man kann so gut wie alles includen.

An der Stelle, wo wir das nun eisetzen, wird der Inhalt der datei.php in unsere Seite eingebunden.
Zu beachten ist, das der Parsemodus für die include Dateien automatisch auf html geschaltet ist, und somit müssen wir den vorhandenen PHP Code der include dateien wieder mit <? und ?> kennzeichnen.
Der html Code kann einfach in die Datei geschrieben werden.

Hier ein kleines verdeutlichungs Beispiel:
Die Ausgangsdatei:
HTML Code:
<html>
<head>
</head>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="2"><img src="headergrafik.jpg"></td></tr>
<tr><td>
<a href="index.php"><b>Startseite</b></a><br />
<a href="#"><b>link</b></a><br />
<a href="#"><b>link</b></a><br /></td>
<td><b>Hier steht der Ihnalt</b></td></tr>
</table>
</body>
</html>
Da der Grundaufbau unserer Dateien gleich ist, und sich nur der Inhalt ändert, machen wir jetzt daraus 3 Dateien und trennen somit das Aussehen von dem Inhalt. 2 Dateien bestimmen das Aussehen der Seite und sind bei jeder Unterseite gleich, die 3te Datei trägt nur den eigentlichen Inhalt, so wie das bei den Frameseite auch der Fall ist.

Datei nr1 head.php:
HTML Code:
<html>
<head>
</head>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr><td colspan="2"><img src="headergrafik.jpg"></td></tr>
<tr><td>
<a href="index.php"><b>Startseite</b></a><br />
<a href="#"><b>link</b></a><br />
<a href="#"><b>link</b></a><br /></td>
<td>
Datei nr2 footer.php:
HTML Code:
</td></tr>
</table>
</body>
</html>
Datei nr3 index.php:
PHP Code:
<? include ("head.php"); ?>
<b>Hier steht der Inhalt</b>
<? include ("footer.php"); ?>
Um eine neue Unterseite anzulegen, brauchst du nur noch eine Datei mit reinem Inhalt (nach dem Muster der index.php) zu erstellen und einen neuen Link in die head.php einzutragen.

Wie schon oben erwähnt, ist diese Metode auch sehr praktisch zum Einbinden von Newsblöcken und Ähnlichem was sich ständig ändert.
Dafür includen wir einfach eine weitere Datei die wir news.php nennen.

So werden die Ändereungen in einer einzigsten Datei auf das gesammte Projekt übernommen.

Viel Spaß mit dem Includen und vergesst Frames.

PS: THX wären nett. Das Schreiben hat dann doch ne gewisse Zeit gedauert^^
Milchschokolade is offline  
Old 04/19/2011, 20:08   #2
 
greenst0rm's Avatar
 
elite*gold: 0
The Black Market: 305/0/0
Join Date: Dec 2009
Posts: 3,616
Received Thanks: 484
was ich persönlich besser finde:
Nur ein File includen am Anfang des PHP Scripts und mit Funktionen alles definieren, spart tipparbeit
greenst0rm is offline  
Old 05/10/2011, 16:41   #3
 
sava's Avatar
 
elite*gold: 1
Join Date: Dec 2006
Posts: 360
Received Thanks: 135
Hi,

include hin oder her, meist benutzt wird require_once.

Schreib doch noch ein wenig über die Sicherheit beim include.

Mfg
sava is offline  
Reply


Similar Threads Similar Threads
Db Devil Time Frames
12/09/2012 - CO2 Guides & Templates - 21 Replies
Alright, I've searched all over the Co2 forums and have read ridiculous formulas and methods. This is official information straight from the Co2 site and also confirmed with the CO customer desk lol. Cynthia: Water Devil, spawns every 31600 seconds. It appears after the server Maintenance by 6 hours in Island (1) in one of the places. It appears again, after 11:30 hours from killing it, in Island (2) It appears again, after 12:30 hours from killing it, In Island (3) Now with that...
[Request] Demigod Frames
07/09/2010 - Mabinogi - 6 Replies
Right now i'm trying to locate frames of Demigod and add them to my robe, but I don't know what the frames are. Does anyone know the frames of Demigod (excluding wings)?
Grafik/Frames Problem
03/04/2009 - Technical Support - 19 Replies
Hi, mein Problem ist, dass seit ich ein neues Mobo habe, die Frames bei GW im Keller sind. Ich habe einen Intel Pentium D @ 2,8 GHz, Asus P5Q Pro und eine 7950 Gx2. Habe das Mobo eingebaut und Vista Ultimate installiert. Die Frames in Guild Wars sind seitdem bei Grafik einstellung Low bei 15-20fps. Früher waren es 60-70fps auf high. Woran könnte es liegen?
More Frames Per Second
12/17/2007 - Conquer Online 2 - 17 Replies
"The Birdmen problem" Every archer above lvl 120 knows it : when you are plvling your water taos or other noobs in bird island then you are always lagging . You only have 2 frames per second and your ping always goes up to 1000ms. Solution - Remove all effects which increases your performance in twin city and market but there is almost no improvement at the birdmen spawns .
What are frames?
12/11/2005 - Diablo 2 - 1 Replies
http://www.elitepvpers.com/forum/index.php?...f=106 &t=9401&s= First in that guide he tolds something about frames. What are those "frames" can some1 pls tell me text2schild.php?smilienummer=1&text=yes im noob' border='0' alt='yes im noob' />



All times are GMT +2. The time now is 06:01.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.