PHP is pretty good at information processing. The language syntax is represented by a full-featured set of functions for comparing, processing strings, and comparison operators.
Any algorithm is a sequence of choices and actions. But before you make a choice, you need to compare something with something. Strings are the most capacious, efficient and practical mechanism for controlling the algorithm. Rows - a variant of data representation. And data is the main subject of "concern" of any algorithm.
Conventional comparison-action logic
, , PHP . - , , , ( ).
, gettype () 'integer' 'double'.
is_int () is_numeric (). , , , ( 'string', , ).
- , PHP ('==', '===', '!=', ...) . , , . - .
, PHP . , . .
PHP- "" strpos () - , . , .
, - .
$cResult = scCheckFileName($cStr) 'true', , . '.docx' : , '_', '-'.
: $cPtr = '/^([a-zA-Z...0-9\-\_]{4,239})\.(html|js|css|png|jpg|docx|txt){1}$/u'. (, PHP " , ") html, js, css, ...
strpos () preg_match () - . . - , .
PHP:
- , . , - . .
PHP: int strcmp (s1, s2).
:
, , PHP ( ) . strpos (), .
strcmp () - . , PHP strcasecmp(). .
, . PHP ( ) strncmp (s1, s2, N). N-. strcmp ().
,
. , , , .
. implode(array, symbol), : $margins1 = implode(', ', $style->getInnerMargin()); ... / ...; $margins2 = implode(', ', $style->getInnerMargin()) .
PHP- : $check = strcmp ($margins1, $margins2) , - ( ). , . .
PHP ( ) - .
. , , . (put) (get).
, . "" , , .
, . (). , , , .
PHP , , . .
Sure, the functionality is good, but its use can be transferred to the semantic part of the code, to objects. When an algorithm is presented as a system of interaction of objects, it looks much better than a sequence of comparisons and actions in a direct, sequential, classical style.