1.2.1276. Unpreprocessed Values¶
Preprocessing values is the preparation of values before PHP executes the code.
There is no macro language in PHP, that prepares the code before compilation, bringing some comfort and short syntax. Most of the time, one uses PHP itself to preprocess data.
For example : could be written and avoid preprocessing the string into an array first.
Preprocessing could be done anytime the script includes all the needed values to process the expression.
This is a micro-optimisation, in particular when the expression is used once.
<?php
$days_en = 'monday,tuesday,wednesday,thursday,friday,saturday,sunday';
$days_zh = '星期-,星期二,星期三,星期四,星期五,星期六,星期日';
$days = explode(',', $lang === 'en' ? $days_en : $days_zh);
?>
1.2.1276.1. Connex PHP features¶
1.2.1276.1.1. Suggestions¶
Preprocess the values and hardcode them in PHP. Do not use PHP to calculate something at the last moment.
Use already processed values, or cache to avoid calculating the value each hit.
Create a class that export the data in the right format for every situation, including the developer’s comfort.
1.2.1276.1.2. Specs¶
Short name |
Structures/Unpreprocessed |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
Very high |
ClearPHP |
|
Examples |
|
Available in |