PHP Include

Gestart doorStefano7 reacties46 weergaven

8 berichten · pagina 1 van 1

Stefano

Lid · Topicstarter

Berichten
37
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hier een simpel php scriptje die je voor je website kan gebruiken.
PHP Include.
Je kent het wel: www.domein.nl/index.php?p=one2xs

[COLOR= #0000BB]<?php
$p[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]] ))
{[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"$p.html"[/COLOR][COLOR= #007700]);
}[/COLOR] ?>


Zet deze code op de plaats waar jij je de pagina wil hebben in bijvoorbeeld je index.
Voorbeeld: Maak een pagina aan en geef die als naam: /one2xs.html

<a href="index.php?p=one2xs"></a>


Hij laat dan je pagina die je in one2xs.html hebt staan zien.
Het lijkt op iframe alleen dan PHP include winkSucces ermee.
0
Stefano

Lid · Topicstarter

Berichten
37
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Vragen kan je altijd in pm of in dit topic bye
0
Berichten
46
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Huuuh? Hoe kan je dit in godsnaam gebruiken? Zo onveilig als de pest.

Neem dit script (niet zelf gemaakt):

[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]// verander als je paginas in een andere directory staan[/COLOR]
[COLOR= #0000BB]$dir[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"./paginas/"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// naam van de homepage (home.php of index.php)[/COLOR]
[COLOR= #0000BB]$index[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"home"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// naam van de 404 pagina niet gevonden pagina[/COLOR]
[COLOR= #0000BB]$p404[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"404"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$page[/COLOR] [COLOR= #007700]= ([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]]) ?[/COLOR] [COLOR= #0000BB]$_GET[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]p[/COLOR][COLOR= #007700]] :[/COLOR] [COLOR= #0000BB]$index[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$page[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/basename"]basename[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$page[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/file_exists"]file_exists[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dir[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$page[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]".php"[/COLOR][COLOR= #007700])) {[/COLOR]
   [URL="http://www.php.net/require"]require[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dir[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$page[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]".php"[/COLOR][COLOR= #007700]);
}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
   [URL="http://www.php.net/require"]require[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$dir[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$p404[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]".php"[/COLOR][COLOR= #007700]);
}[/COLOR]

?>
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
als je dat script (bovenaan)
al;s index.php doet
en je pakt index ......
en zowiezo wie include er een html page
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Nielsie:
als je dat script (bovenaan)
al;s index.php doet
en je pakt index ......

Dan pakt het script paginas/index.php

Nielsie:
en zowiezo wie include er een html page
Hoezo niet? Als iemand dat fijn vindt werken kan het toch?
0
Tom

Lid

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Dit hoort trouwens bij tutorials volgens mij.
0
Remi

Lid

Berichten
1.270
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Tom schreef:
Dit hoort trouwens bij tutorials volgens mij.
Nee, dit is geen tutorial maar een kant-en-klaar script wink
0
Tom

Lid

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Kant en klaar, hij staat er wel in twee delenemo.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren