H3S1: PHP syntax library:
H4S1: Open and termination of .php files:
W3Schools: A PHP script is executed on the server, and the plain HTML result is sent back to the browser. A PHP script starts with <?php
and ends with ?>
:
<?php
// PHP code goes here
?>
W3Schools: A PHP file normally contains HTML tags, and some PHP scripting code. H5S1: In.file-envelopment<ch-22> of php | code:
<p>1: <a href="<?php $sql = SELECT //yada-yada, to retrieve this URL from db?>" data-type="URL" data-id="https://developer.wordpress.org/plugins/" target="_blank">dev-WP</a></p>
Hu: Previous to the midterm | appearance of <?php, the file was processed as HTML, and after ?>, it returns to HTML, but even the output, from the PHP-req, will ultimately be transformed, at some level #, to HTML. However, note that all of this, exists in a file, that is nominally suffixed # “.php”. This is a powerful | paradigm, with which to write a mostly | static page, that loads fast, but can still dynamically | read from a db, to pull variable | rows. Other functions that are not immediately necessary for display, I would lazy | load, or defer to a background.php-file, and this represents minimal | loss from my idealistic HTML.front-supremacy | paradigm.
H5S1: Propagation of includes<Turing>:
<?php require 'database.php'; ?>
<p><a href="index.html">Back</a></p>
<p><a href="post.post-number=edit.php">Edit</a></p>
<p>1: <a href="<?php
require 'database.php';
$sql = "SELECT url1 FROM wp_posts WHERE post_ID=1";?>" data-type="URL" data-id="https://developer.wordpress.org/plugins/" target="_blank">dev-WP</a></p>
<p>2: <a href="<?php
require 'database.php';
$sql = "SELECT url2 FROM wp_posts WHERE post_ID = 1";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
echo $row["url2"];
?>" data-type="URL" data-id="https://developer.wordpress.org/plugins/" target="_blank"><?php
$sql = "SELECT text2 FROM wp_posts WHERE post_ID=1";
$result = $conn->query($sql);
$row = $result->fetch_assoc();
echo $row["text2"];
?></a></p>
Hu: You can see here # that I have a <?php require statement, that is closed off, in order to allow for an HTML–section to begin, but later, I have more php-encapsulations<cool!>, but it’s not clear, whether the database.php-inclusion is still activated, or if I have to test it, again. Moreover, in the process of troubleshooting<WP.MIC-H2S39>, I did not want this to be a source of error, so I manually wrote in require ‘database.php’;, in each instance of php-encapsulation #<fbno>, and then removed one, once I had the whole thing working #, without other errors. Lo and behold #, it still worked, and this science–tier<Turing> clears up a 20+ year conundrum in the field of php-programming that any inclusion is propagated, until further notice, down the entire end of the script, even though php.close-tags
H5S2: The significance of the propagation.of-includes is that it increases the degree to which # HTML and php-code can be interwoven, leading to added dimensions of depth to the web experience, without costing load times, or scalability, and without overly.redundant-code, and without sacrificing the utility of inclusion, which is exactly half of the utility, of all server.side–programming<Turing>
H5S3: Propagation of variables, and their values:
Hu: Like includes, variables, and their values # can also be propagated, from an earlier php-encap, to a later | one, seemingly<10/19/22>, down to any length, of the document.
H4S2: Semi-colon termination:
W3Schools: PHP statements end with a semicolon (;
). Hu: Warning, after a variable | declaration statement, if the semicolon | is missing, not only will that line not.be-recognized, but the entire script thereafter, may be broken<3/3><10/22> Hu: The semi-colon is sometimes not necessary, if the line of code, is the last relevant | line in the local | script, but if it is followed by additional lines of relevant | code, then it will cause syntax | errors<WP.MIC-H2S39>
H4S3: Case-sensitivity:
W3Schools: In PHP, keywords (e.g. if
, else
, while
, echo
, etc.), classes, functions, and user-defined functions are not | case-sensitive.
H4S3: Print statement:
echo "Hello World";
Hu: Where echo is the command for print, and the excerpt in parenthesis succeeding is the quote to be printed.
H4S4: Variable declaration:
W3Schools: In PHP, a variable starts with the $
sign, followed by the name of the variable:
<?php
$txt = "Hello world!";
$x = 5;
$y = 10.5;
?>
Hu: A variable declaration has 3 parts: the $ syntax, announcing to the system # that what succeeds, is a variable, the name of the variable, adhered to the $, and the value assigned to the variable, which can be a string, integer, or a number of other data types accepted by PHP. W3Schools: Variable name rules:
Rules for PHP variables:
A variable starts with the $ sign, followed by the name of the variable
A variable name must start with a letter or the underscore character
A variable name cannot start with a number
A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
Variable names are case-sensitive ($age and $AGE are two different variables)
H5S1: String declaration: W3Schools: A string can be any text inside quotes. You can use single or double quotes:
H5S2: To call a variable | later, make sure to use # the $-symbol also, ie post_content = $txt, in $sql = “UPDATE wp_posts SET post_content= $txt WHERE post_ID=1”; the same syntax should be used when updating the variable.
H5S3<tips.and-tricks>: Any variable to be used in a function best-be defined within the function # or as an argument of the function 10/16/22.
H5S4: Compound value:
$post_title = $_POST["layer"] . '-dash: ' . $_POST["page_name"];
echo $post_title;
Output: 3-dash: flare-m
H5S5: Superglobal call in variable | declaration, MySQL<Turing>:
Hu: Technically, the SET keyword in MySQL initiates a variable | declaration, where the variable is synonymous<Turing> with the column name to.be-updated, whereas the value, the string that enters the column. Since this row is being fed into MySQL, it may have some different requirements, on the format, that, from my experience, is more specific, than an ordinary PHP variable-decl:
MySQL: text1='{$_POST["text1"]}'
PHP: $text1 = $_POST["text1"];
Dev-MySQL: SET
enables you to assign values to variables that affect the operation of the server or clients. H6S1: Superglobals $_GET and $_POST w/ mysql_real_escape_string: See: Ch0cu3r answer: https://forums.phpfreaks.com/topic/297639-parse-error-syntax-error-unexpected-_post-t_variable-in-cxampphtdocsdbinsertphp-on-line-11/var_name
= value
H6S2: Superglobal call in variable declaration, MySQL-inline:
UPDATE dash_{$_GET['author']}_posts
Hu: Here, when the $_GET superglobal call is nested between some static text, the ” encapsulation # is not necessary.
H5S6: Superglobal call in header(“Location:…”
Hu: Again, there is a slightly different requirement # on a declaration to a superglobal, vs a regular variable | call:
Superglobal call: header("Location: ../post.post-number.php?author={$_GET['author']}
Ordinary variable: &post_ID=$post_ID");
H4S5: Comment syntax:
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
H4S6: Termination of an inclusion:
Hu: Research direction: a concise inclusion | termination, especially in files that have, potentially, thousands of inclusions, can reduce code | redundancy, and inefficient, excess loading, as well as active | cost of RAM, and begins to challenge the rigid | top.down–read paradigm, and introduces, to some extent, dynamic | reading, of the compiler, of the script<Turing>
H4S7: Global declarations header:
<?php
// Global requirements, for this script #, and variable declarations #:
require 'database.php';
require '/php_local_libs/db-lib.php';
// This post_ID defines this specific dash-page, and will be smart, as it will be associated with each author-name, in the format
// [author-name]_[layer]_[count]
$post_ID = blind_1_1
?>
Hu: Recall #<H4S1> that all declarations made here # will be in effect, in later activations of php-encapsulation #
H4S8: Variable call:
Hu: Encapsulating a variable | call in curly brackets defines the termination | point of what is the variable, and what is subsequent text: {$post_author_name}
For example:
$sql = "SELECT url1 FROM dash_{$post_author_name}_posts WHERE post_ID=$post_ID";
H5S1: Variable call in a function call<Turing><tips.n-tricks>:
$x = 1;
if (array_key_exists("url$x", $attributes)) {
Hu: This calling-code # will pass the string “url1” into the function.
if (array_key_exists('url$x', $attributes)) {
Hu: This calling-code # will pass the string ‘url$x’ into the function.
H4S9: Echo syntax:
Hu: Echo is the most-used php-function, with at least half the usage, coming during the testing–phase.
H5S1: Separate discrete | stings with a comma, external to the parentheses:
echo "Your username: ", $_SESSION['username']; ✔️
H5S2: A function call, to a function that contains an echo | statement, can be included, in an echo | statement:
echo "Your username: ", sess_super_username_check();
H5S3: An echo statement puts what is in quotes “out into the blank“<Turing>, and WAMP processes the blank of even a .php file as HTML, or CSS<80%><10/22/22> H6S1: The HTML that is echoed earlier, and this is best reflected in the construction of a table:
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
Hu: Can have a propagating-E<Turing> on subsequent HTML–echoes, providing an architecture for the form of display, even of what comes out of the PHP, and only what echoes comes out of the PHP, so it will all exist, as if PHP, were on a lower layer; this echo multi-threading of from-PHP into the display | layer makes WAMP programming 3-dimensional.
H3S2: Data types:
W3Schools: PHP supports the following data types:
String, Integer, Float (floating point numbers - also called double), Boolean, Array, Object, NULL, Resource
H3S3: PHP functions library:
W3Schools: PHP has more than 1000 built-in functions, and in addition you can create your own custom functions. A user-defined function | declaration starts with the word function
:
function functionName() {
code to be executed;
}
H4S1: Curly brace syntax:
W3Schools: In the example below, we create a function named “writeMsg()“. The opening curly brace ( { ) indicates the beginning of the function code, and the closing curly brace ( } ) indicates the end of the function. The function outputs “Hello world!”. To call the function, just write its name followed by brackets ():
<?php
function writeMsg() {
echo "Hello world!";
}
writeMsg(); // call the function
?>
H4S2: PHP function arguments:
W3Schools: Information can be passed to functions through arguments. An argument is just like a variable. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma. The following example has a function with one argument ($fname). When the familyName() function is called, we also pass along a name (e.g. Jani), and the name is used inside the function, which outputs several different first names, but an equal last name:
<?php
function familyName($fname) {
echo "$fname Refsnes.<br>";
}
familyName("Jani");
familyName("Hege");
familyName("Stale");
familyName("Kai Jim");
familyName("Borge");
?>
Hu: An argument acts as, and is governed by, a variable, but defined temporarily, in the function header, and used, only internally to the function. The same $ syntax<H3S1-H4S4> is used. The main difference # is that the value for the variable is not defined in the function-definition; rather, it is defined on a per-call | basis, in the function call | itself; the variable will be set to have that value # for the duration of the execution of this func-call | only, and its value will be reset to “”, once the ouput is completed.
H5S1: A function with 2 arguments: W3Schools:
<?php
function familyName($fname, $year) {
echo "$fname Refsnes. Born in $year <br>";
}
familyName("Hege", "1975");
familyName("Stale", "1978");
familyName("Kai Jim", "1983");
?>
H5S2: Optional arguments:
Hu: Optional arguments can be established by setting a $variable in argument # that contains a default value, such that if no explicit override is passed in a function call, that default | value is used:<geeksforgeeks>:
<?php
function travel($place = "Sweden") {
return "Traveling to $place.\n";
}
echo travel();
echo travel("Australia");
echo travel("Tokyo");
?>
Output: Travelling to Sweden. Traveling to Australia. Traveling to Tokyo.
H6S1: Eg-2:
function origin_create($check_bool = 'off') {
$origin_socket = socket_create(AF_INET, SOCK_STREAM, 0);
if ($check_bool == 'on') {
origin_check($origin_socket);
}
return $origin_socket;
}
Hu: From flare/testing/echo.socket-create,error.php; will only run origin_check( if ‘on’ is passed as an argument, as a string<Turing>
H4S3: Conditional statements:
Hu: A conditional statement is a structure inside PHP, not necessarily a pre-built function; however, several types of functions can be constructed, by mix-and-matching several components of this structure: H5S1: Simple conditional: W3Schools: Output “Have a good day!” if the current time (HOUR) is less than 20:
<?php
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
}
?>
Hu: Note that this conditional | statement was not written inside of a function, and, therefore, runs, always, when the script is run, and its argument was predefined; since there is no explicit | function call, it will use the value for the variable defined earlier, in the line $t = date(“H”); H5S2: If else conditional, with 2 action | triggers: W3Schools: Output “Have a good day!” if the current | time is less than 20, and “Have a good night!” otherwise:
<?php
$t = date("H");
if ($t < "20") {
echo "Have a good day!";
} else {
echo "Have a good night!";
}
?>
H4S4: Pre-existing functions:
Hu: Built-in functions in PHP can be called without having to be defined within the script, eg. H5S1: W3Schools: The PHP strlen()
function returns the length of a string.
<?php
echo strlen("Hello world!"); // outputs 12
?>
Hu: If a function call in a script file refers to a function that is not defined in the file, or elsewhere, within the program, then it is a pre-existing | function.
H4S5: get_results:
<dev-WP>: wpdb::get_results( string $query = null, string $output = OBJECT ): array|object|null Retrieves an entire SQL result set from the database (i.e., many | rows). Hu: As with all $wpdb | functions, get_results is defined in wp-includes/wp-db.php and can be called if the $wpdb variable is made | available | globally. This is not a built-in | function to PHP, but is pseudo.built-in, when one has access to the wp-db.php file, in one’s folder | directory, in a PHP project, which may be due to # a WP-install, or from copy-pasting this file from the open-source | project. The function is locally–defined in wp-db.php, but is made available, to any other file, using the include pathway<Turing><a-r> #repeatable-content
H4S6: Request, include:
Hu: // copy-pasta from Anki
H5S1: include_paths:
<php.net/functions.include.php>: If a path is defined — whether absolute (starting with a drive letter or \
on Windows, or /
on Unix/Linux systems) or relative to the current directory (starting with .
or ..
) — the include_path will be ignored altogether. For example, if a filename begins with ../
, the parser will look in the parent directory to find the requested file.
H6S1: Absolute path:
include 'C:\wamp64\www\personal-dash\php_local_libs\login.functions-inc.php';
Hu: When there are any errors in the include | path, the safest | option is to simply specify the absolute | path, which has to be in this format 1) C: starts the URL, rather than http://; 2) all the slashes are forward<80% 10/19/22>
H6S1: Relative | path:
../login.php
Hu: ../ specifies the parent | folder, to the folder of the script that includes the relative | path # H7S1: Relative | path to a parallel | folder, or descendant | cousin<Turing!>
../php_local_libs/login.php
Hu: This code will first mine to the ancestor, of both folders, then dig into the parallel | sibling-folder<r: Ch-33, MRCA>
H4S7: Security and formatting functions:
H5S1: <php.net>: htmlspecialchars — Convert special characters to HTML entities:
htmlspecialchars(
string $string,
int $flags = ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401,
?string $encoding = null,
bool $double_encode = true
): string
<php.net>: Certain characters have special | significance in HTML, and should be represented by HTML entities if they are to preserve their meanings. This function returns a string with these conversions made. H5S2: <php.net>: mysql_real_escape_string — Escapes special characters in a string for use in an SQL statement:
mysql_real_escape_string(string $unescaped_string, resource $link_identifier = NULL): string
<php.net>: Escapes special characters in the unescaped_string
, taking into account the current character set of the connection so that it is safe to place it in a mysql_query(). If binary | data is to be inserted, this function must be used.
H5S3: Research suggestion: Caswell<link>: Yes, you need to validate the data that’s coming from the GET super global and ideally you should use PDO parameter binding as @Mark Niebergall suggested. From: https://utos.slack.com/archives/C0C6KAFA8/p1666231418972059
H4S8: return:
<php.net>: If called from within a function, the return
statement immediately ends execution of the current function, and returns its argument as the value of the function call. return
also ends the execution of an eval() statement or script file.
<php.net>: If called from the global scope, then execution of the current script file is ended. If the current script | file was included or required, then control is passed back to the calling file. Furthermore, if the current script file was included, then the value given to return
will be returned as the value of the include call. If return
is called from within the main script file, then script execution ends.
H5S1: Returning values:
<php.net>: Values are returned [from functions] by using the optional return statement. Any type may be returned, including arrays and objects. This causes the function to end its execution immediately and pass control<big-concept!> back to the line from which it was called. A function can not return multiple values, but similar results can be obtained by returning an array.
H5S1: Returning arrays:
H6S1: Returning an associative array:
class K_POP_Star {
public $company = "JYP";
public $country = "Korea";
public $genre = "Pop";
public $genre_2 = "Rap";
public $genre_3 = "Ballad";
public $trait_1 = "Athletic";
public $trait_2 = "Talented";
public $trait_3 = "Beautiful";
function get_sci_class() {
return [
"company" => $this->company,
"country" => $this->country,
"genre" => $this->genre,
"genre_2" => $this->genre_2,
"genre_3" => $this->genre_3,
"trait_1" => $this->trait_1,
"trait_2" => $this->trait_2,
"trait_3" => $this->trait_3,
];
}
}
// Instantiating an object of class K_POP_Star:
$yeji = new K_POP_Star();
var_dump($yeji->get_sci_class());
Output:
array (size=8) 'company' => string 'JYP' (length=3) 'country' => string 'Korea' (length=5) 'genre' => string 'Pop' (length=3) 'genre_2' => string 'Rap' (length=3) 'genre_3' => string 'Ballad' (length=6) 'trait_1' => string 'Athletic' (length=8) 'trait_2' => string 'Talented' (length=8) 'trait_3' => string 'Beautiful' (length=9)
H4S9: print_r($variable):
Hu: When an array cannot be printed by echo, print_r can be used <php.net>: displays information about a variable in a way that’s readable by humans. If given an array, values will be presented in a format that shows keys and elements. Similar notation is used for objects.
H3S4: Data types:
Hu: Newbies don’t understand # that PHP is not a transparent | programming language, which means that any of a number of opaque # data types can be assigned to a plainly-named variable<Turing><illegal>, and, in accompaniment #, only certain data.processing–functions can be applied # to process each | data type, and this is a significant source of error<WP.MIC-H2S39>
H4S1: mysqli_result:
W3Schools: Represents the result set obtained from a query against the database. Hu: Nothing about the type yet; array, string, ? W3Schools: Stores whether the result is buffered or unbuffered as an int (MYSQLI_STORE_RESULT
or MYSQLI_USE_RESULT
, respectively). Hu<10% 10/16/22>
H4S2: Callable:
<php.net>: A PHP function is passed by its name as a string. Any built-in or user-defined function can be used.
<?php
// Our closure
$double = function($a) {
return $a * 2;
};
// This is our range of numbers
$numbers = range(1, 5);
// Use the closure as a callback here to
// double the size of each element in our
// range
$new_numbers = array_map($double, $numbers);
print implode(' ', $new_numbers);
?>
Output: 2 4 6 8 10 Hu: The array of numbers, range(1, 5), in the variable $numbers is passed, one by one, through the callable function $double, in order to generate a new | array, containing the results, in the array $new_numbers, which is concatenated as a string to form the printed | result #
H5S1: array_map:
<php.net>: array_map() returns an array containing the results of applying the callback to the corresponding value of array (and arrays if more arrays are provided) used as arguments for the callback. The number of parameters that the callback | function accepts should match the number of arrays passed to array_map().
array_map(?callable $callback, array $array, array ...$arrays): array
H3S5: PHP-operators:
H4S1: In/de-crementing:
<php.net>: PHP supports C-style pre- and post-increment and decrement operators. Note: The increment/decrement operators only affect numbers and strings. Arrays, objects, booleans and resources are not affected. Decrementing null
values has no effect too, but incrementing them results in 1
.
++$a | Pre-increment | Increments $a by one, then returns $a. |
$a++ | Post-increment | Returns $a, then increments $a by one. |
–$a | Pre-decrement | Decrements $a by one, then returns $a. |
$a– | Post-decrement | Returns $a, then decrements $a by one. |
$a = 5;
echo "Should be 5: " . $a++ . "<br />\n";
echo "Should be 6: " . $a . "<br />\n";
Output: Should be 5: 5
Should be 6: 6
H4S2: String-concat:
<php.net>: There are two string operators. The first is the concatenation | operator (‘.’), which returns the concatenation of its right and left | arguments. The second is the concatenating assignment operator (‘.=
‘), which appends the argument on the right side to the argument on the left side.
<?php
$a = "Hello ";
$b = $a . "World!"; // now $b contains "Hello World!"
$a = "Hello ";
$a .= "World!"; // now $a contains "Hello World!"
?>
H4S3: Ternary operator:
<?php // Example usage for: Ternary Operator
$action = (empty($_POST['action'])) ? 'default' : $_POST['action'];
// The above is identical to this if/else statement
if (empty($_POST['action'])) {
$action = 'default';
} else {
$action = $_POST['action'];
} ?>
<php.net, language.operators> including [D]<fbno>: The expression (expr1) ? (expr2) : (expr3)
evaluates to expr2 if expr1 evaluates to true
, and expr3 if expr1 evaluates to false
.
H3S6: Classes and objects:
<php.net>: PHP includes a complete object model. Some of its features are: visibility, abstract and final classes and methods, additional magic methods, interfaces, and cloning.
<?php
class SimpleClass
{
// property declaration
public $var = 'a default value';
// method declaration
public function displayVar() {
echo $this->var;
}
}
?>
H4S1: $this:
<php.net>: The pseudo-variable $this is available when a method is called from within an object context. $this is the value of the calling object. Hu:
class K_POP_Star {
public $eye_color = "Hazel";
function get_eye_color() {
return $this->eye_color;
}
}
// Instantiating an object of class K_POP_Star:
$yeji = new K_POP_Star();
echo $yeji->get_eye_color();
Output: Hazel. Last.line-verbal<fbno>: echoes of the obj.$-yeji, its ability to express its eye-color #, returning $this-Yeji’s eye color, where $eye_color was assigned the value of “Hazel”, in line 2. Hu: In order to understand $this, you have to understand a fact a level lower, which is that a class represents an abstract concept called an object, which can be exampled # by living organism, such as a German Shepherd, that has both properties, and things that it does or can express. $this, in the context of an object representative class, refers to the object, as a container noun for actions.
H5S1: $This for properties: When the $this keyword is used to refer to a pre-defined property, in the class, that property, which was defined with a $-prefix, no longer needs to be prefixed, in the call, ie:<Schweitzer, WP.MIC-H2S7,H3S6>
public
$logging = '',
$this->logging = $logger;
H4S2: new:
<php.net>: To create an instance of a class, the new
| keyword must be used. An object will always be created unless the object has a constructor defined that throws an exception on error. Classes should be defined before instantiation (and in some cases this is a requirement). If a string containing the name of a class is used with new
, a new instance of that class will be created. If the class is in a namespace, its fully qualified | name must be used when doing this.
<?php
$instance = new SimpleClass();
// This can also be done with a variable:
$className = 'SimpleClass';
$instance = new $className(); // new SimpleClass()
?>
H4S3: Properties:
<php.net>: Class properties and methods live in separate “namespaces“, so it is possible to have a property and a method with the same | name. Referring to both a property and a method has the same notation, and whether a property will be accessed or a method will be called, solely depends on the context, i.e. whether the usage is a variable access or a function call.
<?php class Foo
{
public $bar = 'property';
public function bar() {
return 'method';
}
}
$obj = new Foo();
echo $obj->bar, PHP_EOL, $obj->bar(), PHP_EOL;
Output:
property
method
H5S1: Populating the values of properties with external | property sets:
<?php
class automobile {
public $make = '';
public $cost = '';
function automobile_cost() {
return "Your future " . $this->make . " will cost $" . $this->cost;
}
}
$subaru = new automobile();
$subaru->make = "Subaru";
$subaru->cost = 95000;
echo $subaru->automobile_cost();?>
Output: Your future Subaru will cost $95000. Tested in class.instantiation-method,change.test.php of www/flare.
H4S4: extends: parent-child:

H4S5: Visibility:
<php.net>: The visibility of a property, a method or (as of PHP 7.1.0) a constant can be defined by prefixing the declaration with the keywords public
, protected
or private
. Properties/methods declared without any explicit visibility keyword are defined as public.
H5S1: Public: <php.net>: Class members declared public can be accessed everywhere.
H5S2: Members declared protected can be accessed only within the class itself and by inheriting and parent classes.
H5S3: Members declared as private may only be accessed by the class that defines the member.
<php.net>: A class can inherit the constants, methods, and properties of another class by using the keyword extends
in the | class | declaration. It is not possible to extend multiple | classes; a class can only inherit from one base class. The inherited constants, methods, and properties can be overridden by redeclaring them with the same | name defined in the parent class. However, if the parent class has defined a method or constant as final, they may not be overridden.
Main line: 12…Rfc8 45.5% 13. a3 Rab8 14. h4 b5 15. Nd5 Qxd2 16. Rxd2 Bxd5! <46.5%> 17. exd5 a5! R: https://lichess.org/dlMeuTjW/black#23
H4S6: Object interfaces:
<php.net>: Object interfaces allow you to create code which specifies which methods a class must implement, without having to define how these methods are implemented. Interfaces share a namespace with classes and traits, so they may not use the same name. Interfaces are defined in the same way as a class, but with the interface
keyword replacing the class
keyword and without any of the methods having their contents defined. To implement an interface, the implements
operator is used. All methods in the interface must be implemented within a class; failure to do so will result in a fatal error. Classes may implement more than one interface if desired by separating each interface with a comma.
H4S7: Object-op: ->
<delftstack.com><a-r>: The object | operator (->
) is used in object-oriented | programming in PHP. It is used to instantiate a class or can be used to access any object in PHP.
H5S1: In the following example, we create a class then instantiate it to access the members of the provided object using the object operator (->
).
<?php $demo_obj = (object) array('1' => 'John','2' => 'Shawn','3' => 'Michelle');
echo $demo_obj->{'1'};?>
Output: John. Confirmed 11/1/22 ‘basic.class-test.php’ in /www/flare. Hu: An object does not have a 1:1 set overlap with the class | feature as this case, the object is a simple | array.
The object operator (->
) is also used to access the properties of a class.
H4S8: Methods:
Property values can be defaults, and methods can be written to change their value.
H3S7: Keywords:
H4S1: Constants:
H5S1: PHP_EOL
(string): The correct ‘End Of Line‘ symbol for this platform.
Definitions:
Instantiate(v.) = represent as or by an instance. <ox-lang>
References:
https://www.w3schools.com/php/php_syntax.asp
https://www.w3schools.com/php/php_datatypes.asp
https://www.w3schools.com/php/php_variables.asp
H4S1: Functions:
https://www.w3schools.com/php/php_functions.asp
https://www.w3schools.com/php/php_ref_overview.asp: refer to for a list of built-in | functions to PHP.
https://www.php.net/manual/en/function.return.php
https://github.com/php/php-src
https://github.com/php/php-src/blob/master/CODING_STANDARDS.md
https://www.php.net/manual/en/functions.returning-values.php
https://www.php.net/manual/en/function.print-r.php
https://www.geeksforgeeks.org/how-to-create-optional-arguments-in-php/
H4S2: HTML x PHP:
https://blog.hubspot.com/website/wordpress-vs-html#thedifferencebetweenhtmlandwordpresswebsite
https://www.php.net/manual/en/function.htmlspecialchars.php
H4S3: PHP x MySQL:
https://www.php.net/manual/en/function.include.php
https://www.php.net/manual/en/ini.core.php#ini.include-path
https://www.php.net/manual/en/function.mysql-real-escape-string.php
https://dev.mysql.com/doc/refman/8.0/en/set-statement.html
https://www.php.net/manual/en/language.operators.increment.php
https://www.php.net/manual/en/language.operators.string.php
H4S4: Classes:
https://www.php.net/manual/en/language.oop5.basic.php
https://www.php.net/manual/en/oop5.intro.php
https://www.php.net/manual/en/language.oop5.visibility.php
https://www.php.net/manual/en/language.oop5.interfaces.php
https://www.delftstack.com/howto/php/php-object-operator/
https://github.com/napengam/phpWebSocketServer/blob/master/server/webSocketServer.php
H4S5: Data types:
https://www.php.net/manual/en/language.types.callable.php
https://www.php.net/manual/en/function.array-map.php
H4S6: Operators:
https://www.php.net/manual/en/language.operators.comparison.php