Index: phpdoc/nl/Translators
diff -u phpdoc/nl/Translators:1.12 phpdoc/nl/Translators:1.13
--- phpdoc/nl/Translators:1.12 Sun Nov 12 14:55:50 2000
+++ phpdoc/nl/Translators Tue Nov 14 15:30:07 2000
@@ -115,7 +115,7 @@
basic-syntax.xml Derick done
constants.xml Derick done
control-structures.xml Derick started
-expressions.xml
+expressions.xml Derick done
functions.xml
oop.xml Derick done
operators.xml
Index: phpdoc/nl/language/expressions.xml
diff -u phpdoc/nl/language/expressions.xml:1.1 phpdoc/nl/language/expressions.xml:1.2
--- phpdoc/nl/language/expressions.xml:1.1 Tue Oct 10 15:07:54 2000
+++ phpdoc/nl/language/expressions.xml Tue Nov 14 15:30:07 2000
@@ -1,28 +1,28 @@
- Expressions
+ Expressies
- Expressions are the most important building stones of PHP. In PHP,
- almost anything you write is an expression. The simplest yet
- most accurate way to define an expression is "anything that has a
- value".
+ Expressies zijn de belangrijkste bouwstenen van PHP. In PHP is bijna
+ alles wat je schrijft een expressie. De eenvoudigste en meest
+ accurate manier om een expressie te defineren is "alles dat een
+ waarde heeft".
- The most basic forms of expressions are constants and variables.
- When you type "$a = 5", you're assigning '5' into $a. '5', obviously,
- has the value 5, or in other words '5' is an expression with the
- value of 5 (in this case, '5' is an integer constant).
+ De basis vorm van expressies zijn constanten en variabelen. Als je
+ typt "$a = 5", dan geef je $a de waarde '5'. '5', heeft als waarde
+ (natuulijk) 5, of met andere woorden '5' is een expressie met de
+ waarde 5 (in dit voorbeeld, '5' is een integer constante).
- After this assignment, you'd expect $a's value to be 5 as
- well, so if you wrote $b = $a, you'd expect it to behave just as
- if you wrote $b = 5. In other words, $a is an expression with the
- value of 5 as well. If everything works right, this is exactly
- what will happen.
+ Na deze toekenning verwacht je dat de waarde van $a ook 5 zal zijn,
+ en als je nu zou schrijven $b = $a, dan verwacht je dat dit precies
+ hetzelfde zal doen als $b = 5. Met andere woorden, $a is ook een
+ expressie met de waarde 5. Als alles werkt zoals het hoort, zal
+ $b dus ook de waarde 5 krijgen.
- Slightly more complex examples for expressions are functions. For
- instance, consider the following function:
+ Wat complexere voorbeelden van expressies zijn functies. Kijk
+ bijvoorbeeld naar de volgende functie:
@@ -33,161 +33,169 @@
- Assuming you're familiar with the concept of functions (if you're
- not, take a look at the chapter about functions), you'd assume
- that typing $c = foo() is essentially just like
- writing $c = 5, and you're right. Functions
- are expressions with the value of their return value. Since foo()
- returns 5, the value of the expression 'foo()' is 5. Usually
- functions don't just return a static value but compute something.
-
-
- Of course, values in PHP don't have to be integers, and very often
- they aren't. PHP supports three scalar value types: integer values,
- floating point values and string values (scalar values are values that
- you can't 'break' into smaller pieces, unlike arrays, for instance).
- PHP also supports two composite (non-scalar) types: arrays and
- objects. Each of these value types can be assigned into variables or
- returned from functions.
-
-
- So far, users of PHP/FI 2 shouldn't feel any change. However, PHP
- takes expressions much further, in the same way many other
- languages do. PHP is an expression-oriented language, in the
- sense that almost everything is an expression. Consider the
- example we've already dealt with, '$a = 5'. It's easy to see that
- there are two values involved here, the value of the integer
- constant '5', and the value of $a which is being updated to 5 as
- well. But the truth is that there's one additional value involved
- here, and that's the value of the assignment itself. The
- assignment itself evaluates to the assigned value, in this case 5.
- In practice, it means that '$a = 5', regardless of what it does,
- is an expression with the value 5. Thus, writing something like
- '$b = ($a = 5)' is like writing '$a = 5; $b = 5;' (a semicolon
- marks the end of a statement). Since assignments are parsed in a
- right to left order, you can also write '$b = $a = 5'.
-
-
- Another good example of expression orientation is pre- and
- post-increment and decrement. Users of PHP/FI 2 and many other
- languages may be familiar with the notation of variable++ and
- variable--. These are increment and decrement operators. In
- PHP/FI 2, the statement '$a++' has no value (is not an
- expression), and thus you can't assign it or use it in any way.
- PHP enhances the increment/decrement capabilities by making
- these expressions as well, like in C. In PHP, like in C, there
- are two types of increment - pre-increment and post-increment.
- Both pre-increment and post-increment essentially increment the
- variable, and the effect on the variable is idential. The
- difference is with the value of the increment expression.
- Pre-increment, which is written '++$variable', evaluates to the
- incremented value (PHP increments the variable before reading its
- value, thus the name 'pre-increment'). Post-increment, which is
- written '$variable++' evaluates to the original value of
- $variable, before it was incremented (PHP increments the variable
- after reading its value, thus the name 'post-increment').
-
-
- A very common type of expressions are comparison expressions.
- These expressions evaluate to either 0 or 1, meaning FALSE or TRUE
- (respectively). PHP supports > (bigger than), >= (bigger than
- or equal to), == (equal), != (not equal), < (smaller than) and <=
- (smaller than or equal to). These expressions are most commonly used
- inside conditional execution, such as if
+ Aangenomen dat je bekend met met het concept 'functiens' (als je
+ dit niet bent kijk dan in het hoofdstukk over functies), verwacht je
+ dat het typen van $c = foo() in essentie precies
+ hetzelfde is als het typen van $c = 5, en dit is ook
+ waar. Functies zijn expressies met de waarde die gelijk is aan de return
+ waarde van de functie. Omdat foo() 5 teruggeeft, is de waarde van de
+ expressie 'foo()' 5. Normaal gesproken retourneren functies geen
+ statische waarden natuurlijk, maar berekenen ze iets.
+
+
+ Natuurlijk kunnen waarden in PHP ook iets anders zijn dan integers.
+ PHP ondersteund drie scalaire types: integers, floating points en
+ strings. (Scalaire types hebben waardes die je niet in kleinere stukken
+ kunt breken, dit in tegenstelling tot bijvoorbeeld array's).
+ PHP ondersteund ook twee niet scalaire types: array's en objecten
+ Al deze types kunnen worden toegekend aan variabelen of worden
+ teruggegeven uit functies.
+
+
+ Tot zover zullen de gebruikers van PHP/FI 2 geen verschil merken,
+ maar PHP gaat veel verder met expressies, op dezelfde manier als
+ veel andere talen doen. PHP is een expressie-georiënteerde
+ taal waarbij bijna alles een expressie is. Neem bijvoorbeeld het
+ voorbeeld dat je eerder hebt gezien: '$a = 5'. Het is eenvoudig
+ te zien dat het hier om twee waardes gaat, de waarde van de
+ integer constante '5' en de waarde van $a waaraan 5 wordt
+ toegekend. Maar in werkelijkheid is er nog een waarde, en deze
+ waarde is de waarde van de toekenning zelf. De toekenning zelf
+ evalueert tot de toegekende waarde, in dit geval 5. Dit betekend
+ dat '$a = 5', terzijde gelegd wat het doet, een expressies is met
+ de waarde 5. Dus als je zou schrijven: '$b = ($a = 5)' gebeurd er
+ precies als je zou schrijven: '$a = 5; $b = 5;' (een puntkomma
+ markeerd het einde van een statement). Omdat toekenningen worden
+ geparsed van rechts naar links, zou je ook kunnen schrijven
+ '$b = $a = 5'.
+
+
+ Een ander goed voorbeeld van expressie oriëntatie zijn
+ pre- en post-increment en decrement. Gebruikers van PHP/FI 2
+ en vele andere talen zullen wellicht de notatie variabele++
+ en variable-- kunnen. Dit zijn de increment en decrement
+ operaties. In PHP/FI 2, heeft het statement '$a++' geen waarde
+ (het is geen expressie), en daarom kun je het niet toewijzen
+ of gebruiken op een andere manier. PHP voegt increment/decrement
+ toe aan de expressies, net zoals dit in C is. In PHP zijn er
+ twee types of increment, pre-increment en post-increment.
+ Zowel pre-increment en post-increment verhogen de variabele, en
+ het effect op de variabele is identiek. Het verschil ligt hem
+ aan de waarde van de totale increment expressie. Pre-increment,
+ dat wordt geschreven als '++$variable', evaluaeerd tot de
+ opgehoogde waarde (PHP increments de variabele voordat de waarde
+ wordt gelezen, vandaar de naam 'pre-increment'). Post-increment,
+ dat wordt geschreven als '$variable++' evalueert tot de
+ oorspronkelijke waarde van $variable, voordat deze is
+ opgehoogd (PHP increments de variable nadat deze is uitgelezen,
+ vandaar de naam 'post-increment').
+
+
+ Andere normale expressies zijn vergelijkings expressies. Deze
+ expressies evalueren tot 0 of 1 (dit betekent respectievelijk
+ FALSE en TRUE). PHP ondersteund > (groter dan), >= (groter dan
+ of gelijk aan), == (gelijk), != (niet gelijk), < (kleiner dan)
+ en <= (kleinder dan of gelijk aan). Deze expressies worden meestal
+ gebruikt binnen conditionele statements, zoals if
statements.
- The last example of expressions we'll deal with here is combined
- operator-assignment expressions. You already know that if you
- want to increment $a by 1, you can simply write '$a++' or '++$a'.
- But what if you want to add more than one to it, for instance 3?
- You could write '$a++' multiple times, but this is obviously not a
- very efficient or comfortable way. A much more common practice is
- to write '$a = $a + 3'. '$a + 3' evaluates to the value of $a
- plus 3, and is assigned back into $a, which results in
- incrementing $a by 3. In PHP, as in several other languages
- like C, you can write this in a shorter way, which with time would
- become clearer and quicker to understand as well. Adding 3 to the
- current value of $a can be written '$a += 3'. This means exactly
- "take the value of $a, add 3 to it, and assign it back into $a".
- In addition to being shorter and clearer, this also results in
- faster execution. The value of '$a += 3', like the value of a
- regular assignment, is the assigned value. Notice that it is NOT
- 3, but the combined value of $a plus 3 (this is the value that's
- assigned into $a). Any two-place operator can be used in this
- operator-assignment mode, for example '$a -= 5' (subtract 5 from
- the value of $a), '$b *= 7' (multiply the value of $b by 7), etc.
+ Het laatste type expressies waar we het over zullen hebben zijn
+ gecombineerde operatie-toewijzings expressies. Je weet al dat
+ als je $a wilt verminderen met 1, je '$a++' of '++$a' kunt
+ schrijven. Maar wat als je er meer wailt afhalen, bijvoorbeeld 3?
+ Je zou natuurlijk vaker '$a++' kunnen scjrijven, maar dit is
+ natuurlijk niet efficië of handig. Veel vaker wordt er
+ geschreven '$a = $a + 3'. '$a + 3' evaluaeerd tot de waarde van $a
+ plus 3, en wordt dan weer teruggewezen aan $a, dit resulteert in
+ een nieuwe waarde van $a die 3 onder d ehuidige waarde ligt.
+ In PHP, en in vele andere talen waaronder C, kun je dit korter
+ schrijven, zodat het makkelijker leest en sneller te begrijpen is.
+ Het ophogen van de huidige waarde van $a met 3 kan worden geschreven
+ als '$a += 3'. Dit betekend "neem de waarde van $a, tel er 3 bij
+ op, en ken het weer toe aan $a". Als derde voordeel (naast korter
+ en makkelijker te lezen, zal het statement ook sneller worden
+ uitgevoerd. De waarde van '$a += 3', is net zoals de waarde van
+ een normale toekenning, de toegekende waarde. Begrijp goed dat dit
+ NIET 3 is, maar de gecombineerde waarde van $a plus 3 (dit is
+ namelijk de waarde die wordt toegekend aan $a). Elke binairy
+ operator kan worden gebruikt voor deze operatie-toekennings mode,
+ bijvoorbeeld '$a -= 5' (verminder de waarde van $a met 5),
+ '$b *= 7' (vermenigvuldig de waarde van $b met 7), enz.
- There is one more expression that may seem odd if you haven't seen
- it in other languages, the ternary conditional operator:
+ Er is nog een expressie die vreemd zal lijken als je het nog niet
+ hebt gezien in andere talen, namelijk ternaire conditionele
+ operator:
-$first ? $second : $third
+$eerste ? $tweede : $derde
- If the value of the first subexpression is true (non-zero), then
- it the second subexpression is evaluated, and that is the result
- of the conditional expression. Otherwise, the third subexpression
- is evaluated, and that is the value.
+ Als de waarde van de eerste sub-expressie waar is (niet-nul), dan
+ worde de tweede sub-expressie geevalueerd, en dit resultaat zijn
+ van de conditionele expressie. Anders worde de derde sub-expressie
+ geevalueerd, en wordt dit de waarde van de operatie.
- The following example should help you understand pre- and
- post-increment and expressions in general a bit better:
+ Het volgende voorbeeld helpt je met het beter begrijpen van pre- en
+ post-increment en expressies in het algemeen:
-function double($i) {
+function dubbel($i) {
return $i*2;
}
-$b = $a = 5; /* assign the value five into the variable $a and $b */
-$c = $a++; /* post-increment, assign original value of $a
- (5) to $c */
-$e = $d = ++$b; /* pre-increment, assign the incremented value of
- $b (6) to $d and $e */
-
-/* at this point, both $d and $e are equal to 6 */
-
-$f = double($d++); /* assign twice the value of $d before
- the increment, 2*6 = 12 to $f */
-$g = double(++$e); /* assign twice the value of $e after
- the increment, 2*7 = 14 to $g */
-$h = $g += 10; /* first, $g is incremented by 10 and ends with the
- value of 24. the value of the assignment (24) is
- then assigned into $h, and $h ends with the value
- of 24 as well. */
+$b = $a = 5; /* ken de waarde 5 toe aan de variabelen $a en $b */
+$c = $a++; /* post-increment, ken de originele waarde van $a
+ (5) toe aan $c */
+$e = $d = ++$b; /* pre-increment, ken de opgehoogde waarde van
+ $b (6) toe aan $d en $e */
+
+/* op dit punt zijn $d en $e beide gelijk aan 6 */
+
+$f = double($d++); /* ken twee keer de waarde van $d voor
+ de ophoging, 2*6 = 12 toe aan $f */
+$g = double(++$e); /* ken twee keer de waarde van $e na
+ de ophoging, 2*7 = 14 toe aan $g */
+$h = $g += 10; /* als eerste wordt $g opgehoogd met 10 en eindigt met de
+ waarde 24. De waarde van de toekenning (24) wordt dan
+ toegekend aan $h, zodat ook $h uiteindelijk de waarde
+ 24 krijgt. */
- In the beginning of the chapter we said that we'll be describing
- the various statement types, and as promised, expressions can be
- statements. However, not every expression is a statement. In
- this case, a statement has the form of 'expr' ';' that is, an
- expression followed by a semicolon. In '$b=$a=5;', $a=5 is a
- valid expression, but it's not a statement by itself. '$b=$a=5;'
- however is a valid statement.
-
-
- One last thing worth mentioning is the truth value of expressions.
- In many events, mainly in conditional execution and loops, you're
- not interested in the specific value of the expression, but only
- care about whether it means TRUE or FALSE (PHP doesn't have a
- dedicated boolean type). The truth value of expressions in PHP is
- calculated in a similar way to perl. Any numeric non-zero numeric
- value is TRUE, zero is FALSE. Be sure to note that negative
- values are non-zero and are thus considered TRUE! The empty
- string and the string "0" are FALSE; all other strings are TRUE.
- With non-scalar values (arrays and objects) - if the value
- contains no elements it's considered FALSE, otherwise it's
- considered TRUE.
-
-
- PHP provides a full and powerful implementation of expressions, and
- documenting it entirely goes beyond the scope of this manual. The
- above examples should give you a good idea about what expressions
- are and how you can construct useful expressions. Throughout the
- rest of this manual we'll write expr
- to indicate any valid PHP expression.
+ Aan het begin van dit hoofdstuk vertelden we dat we verschillende
+ statement types zouden beschrijven, en zoals is gebleken kunnen
+ expressies statements zijn. Maar niet iederen expressie is een statement.
+ Een statement heeft de vorm 'expressie' ';' dat is een expressie
+ gevolgt door een punt-komma. In '$b=$a=5;' is $a=5 een geldige
+ expressie, maar niet een statement. '$b=$a=5;' is wel een geldig
+ statement in dit voorbeeld.
+
+
+ Er is nog een laatste ding waar we het over willende hebben, en
+ dat is de waarheids-waarde van expressies. In veel gevallen,
+ vaak in loops en andere conditionele dingen, ben je niet
+ geïnteresseerd in een specifieke waarde, maar alleen of deze
+ waarde TRUE of FALSE betekent. (PHP heeft geen appart boolean
+ type). De waarheidswaarde van expressies in PHP is hetzelfde als
+ dat in Perl. Allen numerieke niet-nul waarden zijn TRUE, 0 is
+ FALSE. Let erop negatieve waardes ook niet-nul zijn en daarom
+ de waarheids-waarde TRUE is!. De lege string en de string "0"
+ zijn ook FALSE; alle andere strings zijn TRUE. In het geval van
+ niet scalaire waarden (array's en objecten) is de waardheids-
+ waarde FALSE als deze geen elementen bevat, anders evalueren ze
+ tot TRUE.
+
+
+ PHP heeft een volledige en krachtige implementatie van expressie,
+ en om dit te documenteren gaat geheel buiten de scope van deze
+ handleiding. De bovenstaande voorbeelden zouden je een goed idee
+ moeten geen over wat expressies zijn en hoe je ze goed kan
+ construeren. In de rest van deze handleiding zullen we
+ expr schrijven om een geldige PHP
+ expressie aan te geven.