[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] [doc-en] master: Changed some tags and single quotes to <code> (#1353)
From: Courtney Pattison via GitHub <noreply () php ! net>
Date: 2022-06-27 21:16:20
Message-ID: We7L2h8raWOoFlJxWHIVK27wa4pZQYTneYXM1W9Uw () main ! php ! net
[Download RAW message or body]
Author: Courtney Pattison (courtneypattison)
Committer: GitHub (web-flow)
Pusher: Crell
Date: 2022-06-27T16:10:22-05:00
Commit: https://github.com/php/doc-en/commit/4decb44c7141a97e348a1235bbb20d930d2baac0
Raw diff: https://github.com/php/doc-en/commit/4decb44c7141a97e348a1235bbb20d930d2baac0.diff
Changed some tags and single quotes to <code> (#1353)
* Changed some tags and single quotes to <code>
* Minor grammar fix.
Co-authored-by: Larry Garfield <larry@garfieldtech.com>
Changed paths:
M language/expressions.xml
Diff:
diff --git a/language/expressions.xml b/language/expressions.xml
index ec94db6bba4..ef78a1d5650 100644
--- a/language/expressions.xml
+++ b/language/expressions.xml
@@ -10,15 +10,15 @@
</simpara>
<simpara>
The most basic forms of expressions are constants and variables.
- When you type "<varname>$a</varname> = 5", you're assigning '5' into
- <varname>$a</varname>. '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).
+ When you type <code>$a = 5</code>, you're assigning <code>5</code> into
+ <varname>$a</varname>. <code>5</code>, obviously,
+ has the value 5, or in other words <code>5</code> is an expression with the
+ value of 5 (in this case, <code>5</code> is an integer constant).
</simpara>
<simpara>
After this assignment, you'd expect <varname>$a</varname>'s value to be 5 as
- well, so if you wrote <varname>$b</varname> = <varname>$a</varname>, you'd \
expect it to behave just as
- if you wrote <varname>$b</varname> = 5. In other words, <varname>$a</varname> \
is an expression with the + well, so if you wrote <code>$b = $a</code>, you'd \
expect it to behave just as + if you wrote <code>$b = 5</code>. In other words, \
<varname>$a</varname> is an expression with the value of 5 as well. If everything \
works right, this is exactly what will happen.
</simpara>
@@ -42,10 +42,10 @@ function foo ()
Assuming you're familiar with the concept of functions (if you're
not, take a look at the chapter about <link
linkend="language.functions">functions</link>), you'd assume
- that typing <literal>$c = foo()</literal> is essentially just like
- writing <literal>$c = 5</literal>, and you're right. Functions
- are expressions with the value of their return value. Since \
<literal>foo()</literal>
- returns 5, the value of the expression '<literal>foo()</literal>' is 5. Usually
+ that typing <code>$c = foo()</code> is essentially just like
+ writing <code>$c = 5</code>, and you're right. Functions
+ are expressions with the value of their return value. Since <code>foo()</code>
+ returns 5, the value of the expression '<code>foo()</code>' is 5. Usually
functions don't just return a static value but compute something.
</simpara>
<simpara>
@@ -61,34 +61,34 @@ function foo ()
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, '<varname>$a</varname> = 5'. It's easy to see \
that + example we've already dealt with, <code>$a = 5</code>. It's easy to see \
that there are two values involved here, the value of the integer
- constant '5', and the value of <varname>$a</varname> which is being updated to 5 \
as + constant <code>5</code>, and the value of <varname>$a</varname> 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 '<varname>$a</varname> = 5', regardless of what it \
does, + In practice, it means that <code>$a = 5</code>, regardless of what it \
does, is an expression with the value 5. Thus, writing something like
- '<varname>$b</varname> = (<varname>$a</varname> = 5)' is like writing
- '<varname>$a</varname> = 5; <varname>$b</varname> = 5;' (a semicolon
+ <code>$b = ($a = 5)</code> is like writing
+ <code>$a = 5; $b = 5;</code> (a semicolon
marks the end of a statement). Since assignments are parsed in a
- right to left order, you can also write '<varname>$b</varname> = \
<varname>$a</varname> = 5'. + right to left order, you can also write <code>$b = \
$a = 5</code>. </simpara>
<simpara>
Another good example of expression orientation is pre- and
post-increment and decrement. Users of PHP and many other
- languages may be familiar with the notation of <literal>variable++</literal> and
- <literal>variable--</literal>. These are <link \
linkend="language.operators.increment"> + languages may be familiar with the \
notation of <code>variable++</code> and + <code>variable--</code>. These are \
<link linkend="language.operators.increment"> increment and decrement \
operators</link>. 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 identical. The
difference is with the value of the increment expression.
- Pre-increment, which is written '++<varname>$variable</varname>', evaluates to \
the + Pre-increment, which is written <code>++$variable</code>, evaluates to the
incremented value (PHP increments the variable before reading its
value, thus the name 'pre-increment'). Post-increment, which is
- written '<varname>$variable</varname>++' evaluates to the original value of
- $variable, before it was incremented (PHP increments the variable
+ written <code>$variable++</code> evaluates to the original value of
+ <varname>$variable</varname>, before it was incremented (PHP increments the \
variable after reading its value, thus the name 'post-increment').
</simpara>
<simpara>
@@ -100,33 +100,33 @@ function foo ()
The language also supports a set of strict equivalence operators: ===
(equal to and same type) and !== (not equal to or not same type).
These expressions are most commonly used inside conditional execution,
- such as <literal>if</literal> statements.
+ such as <code>if</code> statements.
</simpara>
<simpara>
The last example of expressions we'll deal with here is combined
operator-assignment expressions. You already know that if you
want to increment <varname>$a</varname> by 1, you can simply write
- '<varname>$a</varname>++' or '++<varname>$a</varname>'.
+ <code>$a++</code> or <code>++$a</code>.
But what if you want to add more than one to it, for instance 3?
- You could write '<varname>$a</varname>++' multiple times, but this
+ You could write <code>$a++</code> multiple times, but this
is obviously not a very efficient or comfortable way. A much more
- common practice is to write '<varname>$a</varname> =
- <varname>$a</varname> + 3'. '<varname>$a</varname> + 3' evaluates
+ common practice is to write <code>$a =
+ $a + 3</code>. <code>$a + 3</code> evaluates
to the value of <varname>$a</varname> plus 3, and is assigned back
into <varname>$a</varname>, which results in incrementing <varname>$a</varname>
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 <varname>$a</varname>
- can be written '<varname>$a</varname> += 3'. This means exactly
+ can be written <code>$a += 3</code>. This means exactly
"take the value of <varname>$a</varname>, add 3 to it, and assign it
back into <varname>$a</varname>". In addition to being shorter and
clearer, this also results in faster execution. The value of
- '<varname>$a</varname> += 3', like the value of a regular assignment, is
+ <code>$a += 3</code>, like the value of a regular assignment, is
the assigned value. Notice that it is NOT 3, but the combined value
of <varname>$a</varname> plus 3 (this is the value that's
assigned into <varname>$a</varname>). Any two-place operator can be used
- in this operator-assignment mode, for example '<varname>$a</varname> -= 5'
- (subtract 5 from the value of <varname>$a</varname>), '<varname>$b</varname> *= \
7' + in this operator-assignment mode, for example <code>$a -= 5</code>
+ (subtract 5 from the value of <varname>$a</varname>), <code>$b *= 7</code>
(multiply the value of <varname>$b</varname> by 7), etc.
</simpara>
<para>
@@ -186,10 +186,10 @@ $h = $g += 10; /* first, $g is incremented by 10 and ends \
with the </para>
<simpara>
Some expressions can be considered as statements. In
- this case, a statement has the form of '<literal>expr ;</literal>' that is, an
- expression followed by a semicolon. In <literal>'$b = $a = 5;'</literal>,
- <literal>'$a = 5'</literal> is a valid expression, but it's not a statement
- by itself. <literal>'$b = $a = 5;'</literal> however is a valid statement.
+ this case, a statement has the form of '<code>expr ;</code>' that is, an
+ expression followed by a semicolon. In <code>$b = $a = 5;</code>,
+ <code>$a = 5</code> is a valid expression, but it's not a statement
+ by itself. <code>$b = $a = 5;</code>, however, is a valid statement.
</simpara>
<simpara>
One last thing worth mentioning is the truth value of expressions.
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic