Tag: php
How to do something between exact two dates in PHP?
Sometimes you need to show something on your website in timeframe. This snippet will show you how to do it precisely: File: between_dates.php ———————– <?php $showDate = "2019-07-16 20:00:00.0"; $hideDate = "2019-07-22 20:00:00.0"; $timezone = new DateTimeZone('Europe/Warsaw'); $now = new DateTime(); $now->setTimezone($timezone); // If in timeframe if( $now > new DateTime($showDate, $timezone) && $now < […]
How to access language var from PHP in Grav CMS?
Gravs documentation is a little bit harsh on PHP developers that want to write plugins. What can you do in this situation? Look trough source code, check other plugins or var_dump $this object 🙂 I’ve spent some time searching for an answer how to access language var in plugins class. And this is it: Have […]
Add template identifiers in Grav
You can add template id’s to debug your Grav website. Check that: Will output:
Mobile Menu for Modular Page (Grav issue)
I’ve found a solution for problem with with mobile menu in Grav CMS. Read more for details.
How to automatically prepend title in Yii2 application?
Click read more to check gist code.
Simple PHP large file upload test script
I’ve created simple script to test large file uploads using PHP powered servers. Fell free to check it at Gist.
Brutal fix for “Incorrect string value:” error in Matomo (Piwik)
If you’re using Matomo (previously Piwik) on MS IIS and MariaDBÂ and you’re getting a lot of these: [06-Jun-2018 11:56:36 UTC] Error in Matomo (tracker): Error query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: ‘\xC3_\xC6\x92\xC3\x82…’ for column ‘name’ at row 1 In query: INSERT INTO matomo_log_action (name, hash, type, url_prefix) VALUES (?,CRC32(?),?,?) Parameters: array […]
E-mail extraction from an Outlook copied string
Sometimes you need to extract an e-mail address from a format like this: Name Surname <[email protected]> In such cases use this function: /** * Extract mail address from a string * * @param string $emailString * @return mixed match on success, false on error */ function extractEmail( $emailString ) { /** @var string $result **/ […]
Differences between character counting in PHP and Javascript
I’ve recently codded my own validation rules for forms. I’m checking length of a string on a client side and also on a server side (obviously it’s a good practice). After my script went on a production, users started to complain about validation errors (even if data in a form was passed proper). This is […]
How to setup your IIS to handle very long PHP execution?
This might be useful when serving file downloads or uploads using PHP.