[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
Webmasterplein.net • Toon onderwerp - Variabel in echo
Pagina 1 van 1

Variabel in echo

BerichtGeplaatst: 27 mei 2006 17:05
door Remi

Re: Variabel in echo

BerichtGeplaatst: 27 mei 2006 17:30
door KillerSponge
Het volgende regeltje geeft aan wat de syntaxis is van echo:

[code="html"]<? echo 'Dit is een stukje tekst met een '.$variabel.' erin!'; ?>[/code]

Je kan dus strings (stukjes tekst) met variabelen verbeinden dmv een punt. Je moet dan alleen nog even letten op de quotes.

Re: Variabel in echo

BerichtGeplaatst: 27 mei 2006 17:54
door LinkinTED
Je hebt meerdere manieren van variabelen echo'en:

[code="php"]<?php
echo "Er liggen " . $aantal . "appels in de mand";
echo "Er liggen $aantal appels in de mand";
echo "Er liggen {$array['aantal']} appels in de mand";
echo 'Er liggen ' . $aantal . 'appels in de mand';

// en nog wat varianten zijn mogelijk volgens mij.[/code]

Re: Variabel in echo

BerichtGeplaatst: 27 mei 2006 18:51
door KillerSponge
Je moet dus wel op het verschil tussen de dubbele en de enkele quote letten.

Dit mag wel:
[code="php"]<? echo "Dit is een $variabele!"; ?>[/code]

Maar dit niet:
[code="php"]<? echo 'Dit is een $variabele!'; ?>[/code]

Bij enkele quotes mag je dus wel variabelen er gewoon tussen dumpen, bij enkele quotes niet. Het gebruik van enkele quotes is iets minder zwaar voor de server.

Re: Variabel in echo

BerichtGeplaatst: 27 mei 2006 19:32
door Remi
bedankt
Ik heb het met de puntjes gebruikt omdat het midden in een stuk HTML was. En HTML ook gebruik maakt van dubbele aanhalingsteken.
[code="php"]<? echo 'Dit is een stukje tekst met een '.$variabel.' erin!'; ?> [/code]

Re: Variabel in echo

BerichtGeplaatst: 27 mei 2006 22:02
door Derk
Als je " gebruikt controleert PHP of er een variabel in staat en of er enters of regeleindes in staan. ( \n is een enter en \r is een regeleinde). Je kan dus in dubbele quotes variabelen gebruiken. In enkele quotes kan dit niet. Echter worden deze laatste het meest gebruikt omdat die lichter zijn voor de server om te parsen. Verder worden de variabelen meestal buiten de quotes gehouden (dus met de puntjes) omdat dit netter staat en de variabel dan een ander kleurtje krijgt.
Als je proffessioneel wilt lijken gebruik je enkele quotes tenzij je regeleindes of enters wilt toevoegen. Ook bij dubbele quotes word er meestal gewerkt om deze voor aan variabel af te sluiten en dan met de puntjes een variabel neer te zetten Wink

Derk