[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
aan alle goede dingen komt een eind, webmasterplein.net 2003 - 2013
wij danken jullie voor al mooie momenten die dankzij dit forum ontstonden - Derk, Rutger en Stef

Variabel in echo

Je komt er niet helemaal uit bij het scripten? Übergoede functie geschreven? Alles met betrekking tot scripting, kun je hier terecht.

Variabel in echo

Berichtdoor Remi » 27 mei 2006 17:05

Avatar gebruiker
Remi
wmpr
 
Berichten: 3010
Geregistreerd: 04 apr 2006 15:22

Re: Variabel in echo

Berichtdoor KillerSponge » 27 mei 2006 17:30

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.
Blabla en andere onzin - http://killersponge.nl
Avatar gebruiker
KillerSponge
Beheerder
Beheerder
 
Berichten: 14456
Geregistreerd: 24 aug 2004 13:05

Re: Variabel in echo

Berichtdoor LinkinTED » 27 mei 2006 17:54

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]
Slicer nodig? ( xHTML | CSS | Semantische opbouw | Div )
http://www.iSlice.nl/
Avatar gebruiker
LinkinTED
wmpr
 
Berichten: 131
Geregistreerd: 14 jan 2006 16:47

Re: Variabel in echo

Berichtdoor KillerSponge » 27 mei 2006 18:51

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.
Blabla en andere onzin - http://killersponge.nl
Avatar gebruiker
KillerSponge
Beheerder
Beheerder
 
Berichten: 14456
Geregistreerd: 24 aug 2004 13:05

Re: Variabel in echo

Berichtdoor Remi » 27 mei 2006 19:32

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]
Avatar gebruiker
Remi
wmpr
 
Berichten: 3010
Geregistreerd: 04 apr 2006 15:22

Re: Variabel in echo

Berichtdoor Derk » 27 mei 2006 22:02

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
Afbeelding
Avatar gebruiker
Derk
Beheerder
Beheerder
 
Berichten: 12634
Geregistreerd: 27 nov 2003 19:50
Woonplaats: Houten


Keer terug naar PHP, ASP, SQL



cron