Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Articles Tagged ‘php’

Work on your php.ini .. easy as 1, 2, 3 at Servage

Thursday, February 11th, 2021 by Helge
The php. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. You can check your default settings if you create a  hands-coffee-cup-apple-largephp file in your root directory and add this code to that file <?php phpinfo() ?> However, some plugins and themes require different PHP settings than those set by default. Via your Servage account, you have a vast flexibility and you can adjust many settings in accordance to your needs! In your Servage control panel, you find the PHP config button which allows you to edit some common php.ini settings: log in ...

Why it is important to upgrade PHP for your website?

Wednesday, October 7th, 2020 by Helge
On November 30, 2020, the support for PHP 7.2 will stop. This means that this version will stop being maintained and security updated by its developers - you who use PHP 7.2 or earlier today therefore need to upgrade to a later PHP version. … But what are the benefits of upgrading to a later PHP version? See below.index Two benefits of using the latest PHP version on your website Higher security An up-to-date PHP version is continuously updated to close any security holes and vulnerabilities. If you continue to use a PHP version that is no longer reviewed by its developers, your website may be compromised. Better performance Newer versions of PHP are ...

Local development with PHP and MySQL

Tuesday, December 17th, 2019 by Helge
newpic Developing quickly and efficiently is important to create value for your users. Having an environment which endorses swift programming and designing really helps you satisfy your customers better. So, how do you develop your web apps? Are you always working on the live code on the webserver? Or are you using advanced version control systems to roll out tested changes? Are you testing on a local machine, uploading your changes every now and then? Obviously there are some serious considerations and risk assessments to make. . However, this article wont judge your development practices. This one is about development on a local machine. Server software You need the proper server software on your ...

Variable-typing in PHP

Tuesday, April 16th, 2019 by Servage
php-explorer-tab-search PHP is a very loosely typed language. This means that variables do not have to be declared before they are used, and that PHP always converts variables to the type required by their context when they are accessed. For example, you can create a multiple-digit number and extract the "nth" digit from it, simply by assuming it to be a string. In the following snippet of code the numbers 12345 and 67890 are multiplied together, returning a result of 838102050, which is then placed in the variable $number. Automatic conversion from a number to a string <?php $number = 12345 * 67890; echo substr($number, 3, 1); ?> At the point of the assignment, $number is a numeric variable. ...

Running terminal commands with PHP

Friday, March 15th, 2019 by Servage
terminalSometimes you may find yourself in a situation where you want to run more than just PHP code. Perhaps PHP does not have a built-in function for what you want to do or you want to run some custom commands, such as executing an external program. There are multiple ways to achieve this, and we will learn how to do it in two different ways. The usual way: exec() and shell_exec() These two functions are likely the ones that come to your mind first when thinking about a way to execute a terminal command. Both of there are basic PHP functions, and they are very similar to each other. The biggest difference between ...

Send PHP errors per mail

Monday, June 25th, 2018 by Servage
Error-handling in PHP can be complex, and getting a good way of having clear and good error reporting and maintaining security, by not displaying to much to the public, can be difficult. Maybe sending errors to developers per email could be a good tool for you. Check out the following example code: // Our custom error handler function nettuts_error_handler($number, $message, $file, $line, $vars) { $email = " <p>An error ($number) occurred on line <strong>$line</strong> and in the <strong>file: $file.</strong> <p> $message </p>"; $email .= "<pre>" . print_r($vars, 1) . "</pre>"; $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Email the error to someone... error_log($email, 1, 'you@youremail.com', $headers); // Make sure that you decide how to respond to errors (on the user's side) // Either ...

HTML parser in PHP

Tuesday, April 24th, 2018 by Servage
Are you ever struggling with HTML content in PHP? Do you need to parse a HTML source? Going through a HTML document in order to extract data might seem like a complicated, or even wrong, way of approaching a problem. Surely there must be another way... Well, sometimes other ways aren't available, sometimes the quick and dirty HTML extraction is simply the easiest way to get things done. Therefore you might find yourself in situations where a working HTML parser for PHP would be a real help. PHP Simple DOM Parser by C.C. Chen is a PHP class that does exactly what I described above. It's available from Sourceforge. It can ...

Create nice documentation for your PHP code

Tuesday, April 3rd, 2018 by Servage
It's a common problem amongh developers that insufficiently or no documentation of code causes problems, delays, misunderstandings. Even code you wrote yourself could look really strange after a while, when you no longer remember what's exactly going on. At this point a good documentation could help you save time and nerves. PhpDocumentor is a good script that generates documentation for your code based on inline comments in your script files. It can generate various output formats, has different themes, and is very customizable. It only requires that you actually commend your code. You can read how to comment your code easily in the PhpDocumentor manual. There are a ...

PHP Handler Engines Explained

Thursday, December 21st, 2017 by Servage
phpAlmost all PHP developers must have heard of either mod_php, PHP-FPM or FastCGI before. However, you might not be aware of what they actually are and do behind the scenes of a web server or how they are different from each other. These handlers are a base requirement for the PHP language to run on web servers so it’s good to know how they operate. PHP Handlers Explained Briefly Regardless of what PHP handler a web server uses, the process of executing PHP code is mostly the same. A web server receives a request to serve a PHP page. It then sends the request to a PHP handler which processes the request, and ...

Documenting PHP APIs

Friday, December 8th, 2017 by Servage
APIA good documentation is a requirement for a good API. If you make a good public API but the documentation is lacking, your API will not see as big of an adoption as it would with a well-written developer-friendly API. Let’s have a look at how to write documentation for a PHP-based API and also what a documentation should have, no matter what language it is written in. Writing a Good API Documentation Before looking at how to write API documentation, let’s consider the things a documentation should have. We will be focusing on a REST API, although the points mentioned usually apply to other types of APIs as well. First of all, every ...