Use an expression to select an array value in PHP. It's handy for quick output logic. Update: it's a bit too clever, perhaps, versus using the tenary operator.
$classes .= [ ' sort-default', ' sort-custom' ][ has_custom_sort( $post ) ];
7 results found.
Use an expression to select an array value in PHP. It's handy for quick output logic. Update: it's a bit too clever, perhaps, versus using the tenary operator.
$classes .= [ ' sort-default', ' sort-custom' ][ has_custom_sort( $post ) ];
So for nginx it is not straightforward to setup PHP-FPM so that PATH_INFO is correctly populated. Lamb uses the following /index.php/some/other type routing, where /some/other should be the PATH_INFO. Instead I want to make setup for a variety of web-servers straightforward, so I've switched to the more robust REQUEST_URI. This simplifies nginx configuration and Caddy and the PHP built-in web-server are compatible.
REQUEST_URI contains everything after the domain name, including the query string, so that needs to be removed:
$request_uri = '/home';
if ( $_SERVER['REQUEST_URI'] !== '/' ) {
$request_uri = strtok( $_SERVER['REQUEST_URI'], '?' );
}
We can see that for a request for the root of the site, REQUEST_URI returns / whereas PATH_INFO would be empty, so the code above takes that into account. We can then deduct a router action as follows:
$action = strtok( $request_uri, '/' );
Once the $action is known, it can be checked against an allowed list of actions:
switch ( $action ) {
case 'edit':
...
break;
default:
respond_404();
break;
Don't think you want to make it this simple to pipe potentially unsafe input to the shell #PHP <a href="http://php.net/manual/en/language.operators.execution.php">[http://php.net/manual/en/language.operators.execution.php</a><p>](http://php.net/manual/en/language.operators.execution.php</a><p>) </p>
PHP 5.5 will no longer support Windows XP and 2003. Those systems are around a decade old, so PHP is pulling the plug on them.
It was already mentioned on the PHP 5.4 release changelog. It makes sense, but I’m sure it will cause some issues with organisations who have not been paying attention. I would encourage all developers to sign up for the PHP Announcements mailinglist. #link #php
If you are looking for guidance on how how to format your code, you could do worse than to base it this coding standards styleguide.
For those that do not follow me on twitter (@pacifika), I've created a patched version of Textile, the html generator alternative to Markdown, to make it easier to use in CodeIgniter projects. I have provided the patch and patched Textile on support forums of both projects.
[Patch] CodeIgniter Helper class patch for classTextile.php · Textpattern CMS Support Forum.
After patching, you can just use Textile like this:
$this->load->helper('textile');
$text = Textile("Dude this is *my* code!");
For more information read the post on the forums!
Our php.log was nearing 550MB so I was investigating how to rotate the logs. The easiest solution seems to be using logrotate (ubuntu linux) with a script like follows.
sudo nano /etc/logrotate.d/php5
/var/log/php5/*.log {
#rotate daily
daily
#keep 14 days
rotate 14
missingok
nocompress
sharedscripts
postrotate
apache2ctl graceful
endscript
}
You can check the configuration by running logrotate --force /etc/logrotate.d/php5