Skip to content
View in the app

A better way to browse. Learn more.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[TUT] [PHP] Variablen en IF commando met Inlcude

Welkom bij deze Tutorial!

Ik ga jullie uitleggen, hoe je d.m.v. variablen kan kijken of iets mag.

We gebruiken hierbij (niet zooo belangrijk maar zeker wel handig) de command Include.

Oke, eerst de sampler.

Class.php:

<?php
$site_state = "online";
$naam = "Mark";
$copy = "Copyright TIMB0 2007 - All rights reserved";
?>

Zoals jullie zien, noem ik deze pagina "Class.php".

Je mag hem noemen zoals je wilt, maar in deze tut gebruik ik deze.

Ik maak in deze pagina (class.php) allemaal variables.

$ <-- variable.

site_state <-- naam variable

= <-- wat hij moet gaan doen

"" <-- nu tekst... dat moet tussen de "" in..

; <-- afsluiten, dat is (haast) altijd bij PHP codes.

Ik maak dus meer variables aan, die ik later waarschijnlijk ga gebruiken.

Nu ga ik de pagina "Index.php" maken, die kan jij uiteraard later zelf hernoemen...

<?php
include("class.php");

If ($site_state == "Online") {
echo "Welkom op mijn site!";
} elseif ($site_state == "update") {
echo "Wij zijn momenteel de site aan het updaten! Kom later terug!";
} else {
echo "De site is momenteel offline! Kom later terug!";
}
?>

Oke, nu ga ik het uitleggen.

include("class.php");

Hiermee roepen wij de pagina Class.php aan, waar de variables in staan.

Heel handig om je pagina netter te houden.

Class.php moet wel in dezelfde map staan!

If ($site_state == "Online") {

Het IF commando, Wanner de variable $Site_state is "online" dan moet je { dit weergeven.

Waarom ==? == checkt tekst, = checkt alleen getallen als ik het goed onthouden heb :)

echo "Welkom op mijn site!";

Heel "simpel" een echo, dus tekst laten zien...

} elseif ($site_state == "update") {

Hetzelfde als de eerste IF uitleg, alleen nu is het ELSEif.

Als het de bovenstaande niet is, maar het is wel "update" dan moet je dit doen...

} else {

Als het niet "online" of "update" is moet je dit weergeven.

}

IF commando afsluiten.

Zo, Hopelijk heb ik dat goed uitgelegd :)

Even wat sampler:

<?php
include("class.php");

If ($site_state == "Online") {
?>
<b>Welkom!!! Ik ben momenteel wel bezig met mijn site :)<br>
Kijk anders even op www.gtaforum.nl :)</b>
<?php
} elseif ($site_state == "update") {
?>
<b>Momenteel zijn wij aan het updaten, kom later terug!</b>
<?php
} else {
echo "De site is momenteel offline! Kom later terug!";
}
?>

Zo, die is wat uitgebreider :)

Je kan nu "simpel" html codes gebruiken zonder dat je rekening hoeft te houden met PHP.

In "online" en "update" dan ;)

Hopelijk heb ik het zo voldoende uitgelegd :)

Suc6!

Vragen zijn altijd welkom!

Edited by Timb0

Featured Replies

= en == zijn twee verschillende operatoren, en het heeft niets te maken met getallen of strings..

De = operator is de toekenning, hij geeft een variabele een nieuwe waarde.

Dus

a = 3; geeft a de waarde 3

a = "help"; geeft a de waarde "help"

De == operator is een evregelijkings operator, daarmee kun je checken of twee waardes gelijk zijn, deze gebruik je bijvoorbeeld in een IF-constructie.

a == 3 is waar als a de waarde 3 heeft

a == "help" is waar als a de waarde "help" heeft.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.