How we can check if variable is defined or if not than get a default value? The general answer is isset and ternary operator let’s simplify this! or after PHP 7.0.1 you can use this shorter way
Archive for the 'php' Category
isset short way
18:45 |
php |
912 views
use regions in MVS2015 for php files
13:12 |
javascript, mvs, php |
1251 views
Goal: I want fold-able code for php like I have to js files The texteditor-like editors are great but without regions your life would be difficult. The Microsoft Visual Studio platform provides a very nice feature to use regions. The simpliest way is the following form – you can use it for javascript The php […]
Goal: I want fold-able code for php like I have to js files The texteditor-like editors are great but without regions your life would be difficult. The Microsoft Visual Studio platform provides a very nice feature to use regions. The simpliest way is the following form – you can use it for javascript The php […]
PHP xDebug – xampp – php 7 – chrome
2:40 |
php, xampp |
1326 views
Goal: not a question, how we can know what is under the hood The PHP debugging is not a trivial case. Could be with the xDebug extension. Follow these steps: A. Xdebug core environment notice: according to the internet you need to disable the output buffering output_buffering = Off for me working with the following […]
Goal: not a question, how we can know what is under the hood The PHP debugging is not a trivial case. Could be with the xDebug extension. Follow these steps: A. Xdebug core environment notice: according to the internet you need to disable the output buffering output_buffering = Off for me working with the following […]
url – parameters as part of the path
9:23 |
php, tricky |
1136 views
Goal: simplify the url A normal url request with parameters looks like this: In many cases we need the following form: how to: 1. we have to accept the invalid request as a normal one. Let’s create a .htaccess file in the root with the following content: 2. receive the parameter in your php code […]
Goal: simplify the url A normal url request with parameters looks like this: In many cases we need the following form: how to: 1. we have to accept the invalid request as a normal one. Let’s create a .htaccess file in the root with the following content: 2. receive the parameter in your php code […]
Get the days between now and the past
0:53 |
php |
985 views
Goal: figure out how to get days between two date I’ve found a page: www.timeanddate.com with many interesting date time function. One of them was duration between two date. If you want to know how many days you lived on the Earth just put your birth date as the first date and the actual date […]
Goal: figure out how to get days between two date I’ve found a page: www.timeanddate.com with many interesting date time function. One of them was duration between two date. If you want to know how many days you lived on the Earth just put your birth date as the first date and the actual date […]
php multiline strings in the code
10:24 |
php |
1080 views
Goal: use multiline strings in the code I have a simple select statement. I want to store it in a variable but I want to forget the concatenation. We can use the heredoc syntax. $query =
Goal: use multiline strings in the code I have a simple select statement. I want to store it in a variable but I want to forget the concatenation. We can use the heredoc syntax. $query =
Get the client country based on ip address
18:05 |
php, web trick |
1889 views
Goal: find the client on the map I was supprised when I examined my server’s stat. There were many client from unknown country. This is not too good. I remember an old solution depends on ip2c database. This is nice and easy, but to keep the database updated not too confortable. 1. database solution I […]
Goal: find the client on the map I was supprised when I examined my server’s stat. There were many client from unknown country. This is not too good. I remember an old solution depends on ip2c database. This is nice and easy, but to keep the database updated not too confortable. 1. database solution I […]
simple browser detection on server side with php
19:20 |
php |
1000 views
Goal: extract basic information from user agent string To follow the user agent strings is like tilting at windmills. My suggestion is a simple way. just implement the minimum and forget the details. Let’s focus on the main browsers and the main operating systems. The first step will be this. Later we will see what […]
Goal: extract basic information from user agent string To follow the user agent strings is like tilting at windmills. My suggestion is a simple way. just implement the minimum and forget the details. Let’s focus on the main browsers and the main operating systems. The first step will be this. Later we will see what […]
switch on php debug mode
12:18 |
php |
1087 views
Goal: get all error message from the server Just put the following 2 lines to the start of your code.
Goal: get all error message from the server Just put the following 2 lines to the start of your code.
no more cache – force the reload based on the file date
8:17 |
php, web trick |
1104 views
Goal: avoid cache in case of changed files The cache is our friend in case of old files. With this code I can use the cache based on my file date. the result is In a little bit friendly shape: Shorter, smarter… Call the no_cache class like
Goal: avoid cache in case of changed files The cache is our friend in case of old files. With this code I can use the cache based on my file date. the result is In a little bit friendly shape: Shorter, smarter… Call the no_cache class like