From a885fa2bce80474eb2632993905bb8b603650a3a Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 5 Oct 2024 21:02:21 +0200 Subject: [PATCH] Depersonalize variables.xml (GH-3835) At least we remove the grossest style guideline violations. This still partly reads like a tutorial, though. And the page is long. --- language/variables.xml | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/language/variables.xml b/language/variables.xml index 93e335e73639..3d0154457e5c 100644 --- a/language/variables.xml +++ b/language/variables.xml @@ -63,7 +63,7 @@ $täyte = 'mansikka'; // valid; 'ä' is (Extended) ASCII 228. By default, variables are always assigned by value. That is to say, - when you assign an expression to a variable, the entire value of + when an expression is assigned to a variable, the entire value of the original expression is copied into the destination variable. This means, for instance, that after assigning one variable's value to another, changing one of those variables will @@ -272,8 +272,8 @@ test(); such diagnostics then nothing at all will be outputted. This is because the echo statement refers to a local version of the $a variable, - and it has not been assigned a value within this scope. You may - notice that this is a little bit different from the C language in + and it has not been assigned a value within this scope. + Note that this is a little bit different from the C language in that global variables in C are automatically available to functions unless specifically overridden by a local definition. This can cause some problems in that people may inadvertently @@ -440,7 +440,7 @@ function test() Static variables also provide one way to deal with recursive functions. A recursive function is one which calls itself. Care must be taken when writing a recursive function because it is - possible to make it recurse indefinitely. You must make sure you + possible to make it recurse indefinitely. It has to be ensured to have an adequate way of terminating the recursion. The following simple function recursively counts to 10, using the static variable $count to know when to stop: @@ -469,7 +469,7 @@ function test() - Prior to PHP 8.3.0, you could only initialize a static variable using + Prior to PHP 8.3.0, static variables could only be initialized using a constant expression. As of PHP 8.3.0, dynamic expressions (e.g. function calls) are also allowed: @@ -640,8 +640,8 @@ Static object: object(stdClass)#3 (1) { This example demonstrates that when assigning a reference to a static - variable, it's not remembered when you call the - &get_instance_ref() function a second time. + variable, it is not remembered when the + &get_instance_ref() function is called a second time. @@ -718,11 +718,11 @@ echo "$a $hello"; - In order to use variable variables with arrays, you have to - resolve an ambiguity problem. That is, if you write - $$a[1] then the parser needs to know if you - meant to use $a[1] as a variable, or if you - wanted $$a as the variable and then the [1] + In order to use variable variables with arrays, + an ambiguity problem has to be resolved. That is, if the parser sees + $$a[1] then it needs to know if + $a[1] was meant to be used as a variable, or if + $$a was wanted as the variable and then the [1] index from that variable. The syntax for resolving this ambiguity is: ${$a[1]} for the first case and ${$a}[1] for the second. @@ -731,7 +731,7 @@ echo "$a $hello"; Class properties may also be accessed using variable property names. The variable property name will be resolved within the scope from which the - call is made. For instance, if you have an expression such as + call is made. For instance, if there is an expression such as $foo->$bar, then the local scope will be examined for $bar and its value will be used as the name of the property of $foo. This is also true if @@ -824,7 +824,7 @@ I am r. - There are only two ways to access data from your HTML forms. + There are only two ways to access data from HTML forms. Currently available methods are listed below: @@ -843,8 +843,8 @@ echo $_REQUEST['username']; - Using a GET form is similar except you'll use the appropriate - GET predefined variable instead. GET also applies to the + Using a GET form is similar except the appropriate + GET predefined variable can be used instead. GET also applies to the QUERY_STRING (the information after the '?' in a URL). So, for example, http://www.example.com/test.php?id=3 contains GET data which is accessible with $_GET['id']. @@ -861,9 +861,9 @@ echo $_REQUEST['username']; PHP also understands arrays in the context of form variables - (see the related faq). You may, - for example, group related variables together, or use this - feature to retrieve values from a multiple select input. For + (see the related faq). + For example, related variables may be grouped together, or this + feature may be used to retrieve values from a multiple select input. For example, let's post a form to itself and upon submission display the data: @@ -941,7 +941,7 @@ if ($_POST) { PHP transparently supports HTTP cookies as defined by RFC 6265. Cookies are a mechanism for storing data in the remote browser and thus - tracking or identifying return users. You can set cookies using + tracking or identifying return users. It is possible to set cookies using the setcookie function. Cookies are part of the HTTP header, so the SetCookie function must be called before any output is sent to the browser. This is the same restriction @@ -960,8 +960,8 @@ if ($_POST) { - If you wish to assign multiple values to a single cookie variable, you - may assign it as an array. For example: + If multiple values should be assigned to a single cookie variable, + they can be assigned as an array. For example: @@ -977,16 +977,16 @@ if ($_POST) { That will create two separate cookies although MyCookie will now - be a single array in your script. If you want to set just one cookie - with multiple values, consider using serialize or + be a single array in the script. If just one cookie should be set + with multiple values, consider using serialize or explode on the value first. Note that a cookie will replace a previous cookie by the same - name in your browser unless the path or domain is different. So, - for a shopping cart application you may want to keep a counter - and pass this along. i.e. + name in the browser unless the path or domain is different. So, + for a shopping cart application a counter may be kept, + and passed along. I.e.