Servage Magazine

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

Archive for January, 2013

Using global variables in PHP

Tuesday, January 29th, 2013 by Servage
Have you ever wondered how you get access to parameters passed to your PHP scripts via a request? Well, it's fairly simple and PHP provides a range of global variables which are available to you as a developer. Mainly they help you to get access to dynamic information or params. POST and GET parameters These params are passed either as part of the URL or posted from a form. You can access them like this: // Get a param echo $_POST['param']; echo $_GET['param']; // It even works like arrays echo $_POST['param']['subparam']; Server paremeters The $_SERVER global provides various information about the executed script and environment. // Information from the server echo $_SERVER['PHP_SELF']; echo $_SERVER['SERVER_NAME']; Cookies the $_COOKIE global provides possibilities to store and read ...

Extract RSS feeds with PHP

Friday, January 25th, 2013 by Servage
It's very easy to fetch RSS feeds with PHP and use them on your website, if you wish. This could be useful to aggregate information or news from relevant sources, or if you for some other reason need to import or display data which you have available as a feed, SimplePie is a PHP library which provides this support through an easy framework which allows you to extract data in an object oriented way. Nice and easy. Example how to start SimplePie and fetch a feed // Instantiate SimplePie $feed = new SimplePie(); // Define which URL to load the feed from $feed->set_feed_url('https://simplepie.org/blog/feed/'); // Initialize the feed $feed->init(); Use information from the feed // You can get various ...

Active Record implementations for PHP

Tuesday, January 22nd, 2013 by Servage
You should know about Active Record and the benefits it's usage could have for your project. Please consider the following Wikipedia description: "In software engineering, the active record pattern is an architectural pattern found in software that stores its data in relational databases. The interface of an object conforming to this pattern would include functions such as Insert, Update, and Delete, plus properties that correspond more or less directly to the columns in the underlying database table." There are many ways of implementing this in your project - most MVC frameworks come with some implementation out of the box. However, you may not want such a framework, or you wish a ...

Embed shared links with live preview

Saturday, January 19th, 2013 by Servage
Have you ever wondered how social media portals create the smart Share-a-link functions, where you get to see a little preview of the page you want to share? It's actually very nice functionality and clever as well. Thankfully such an implementation is not as difficult as you might think. Basically you can circumvent most complexities by using an embed-provider like Embed.ly - who takes care of the difficult part. How does it work? You build your own sharing interface in your web app, but behind the scenes, you request Embed.ly to scrape the posted URL, and it will return with a set of information about the page, which you can use in your ...

Using sessions in PHP

Thursday, January 17th, 2013 by Servage
There are two ways how you can store data associated with a given visitor. You can use cookies on the client or sessions on the server. In this article I will present you with the basic concepts of sessions usage in PHP. First of all, it works so that PHP stores a cookie on the client side with a session ID. This session ID is then used to identify and retrieve a session stored on the server. So you can actually store secret information in the session and be sure it isn't manipulated or seen by the user - unlike cookies which are viewable by the browser. Start the session Before you ...

Using Models in Javascript

Monday, January 14th, 2013 by Servage
Working with a MVC framework on the server adds enormous benefits to your project. So why not do it on the client-side as well? Javascript is perfectly capable of being used for object oriented programming, working with data models that can represent entities in the data base, like active record for example. Backbone.js is a project offering such an interface for your Javascript development. It can automatically handle, sort and use a set of data models, and communicate with a server-side API to perform various actions. "Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions,views with declarative event handling, and connects ...

Beautiful grid-view with HTML5, CSS and Javascript

Saturday, January 12th, 2013 by Servage
Responsive web design is becoming more and more popular, where elements automatically fit to almost any type and size of screen. Elements are quickly resized and positioned based on browser size. This is extremely nice, because it helps you to provide a great user experience on your website, not matter which device and resolution the user has. Most solutions implement standard lists for small screens like mobile phones, and build larger and more complex grids of content the more screen size is available to them. Example of beautiful grid layout These guys have created wonderful grid which displays different content types in various sizes, and positions it according to screen size. You ...

Live updating time-stamps with Javascript

Wednesday, January 9th, 2013 by Servage
Do you want a smart system to show timestamps in a reader-friendly way? For example to display a timestamp as "2 minutes ago", instead of the actual year, month, day, hours, minutes and seconds. For older timstamps it's nice with "Yesterday" or "Last week", while very old ones should simple get the actual timestamp shown. This way of displaying times is very popular e.g. on social media sites and others, which features streams of often updated content. It looks nice and provides a quicker understanding of the time factor. You can implement this in two ways. Either your convert the timestamp on the server, or in the client. The advantage of ...

Get your own server environment with a VPS

Tuesday, January 8th, 2013 by Servage
Do you want you own server? Do you need special software? Are you tired of performance problems? Are you just curious? Well, there are many good reasons to get an own virtual private server. The price is definitely also one of them! Consider this offer from Servage. It's pretty much the same cost as a shared webhosting account! RAM Memory: 256 MB Traffic: 100 GB Diskspace: 50 GB Full root access Power On/Off from CP Backup (snapshots) ACPI shutdown from CP Console access from CP Check out the plans. Cloud Based Server Virtualization The TotalCloud server virtualization offering is based on a modular setup where the servers are clustered in pairs. In these pairs, one server acts ...

Design websites with use-cases

Sunday, January 6th, 2013 by Servage
How often do you visit a website and want to do something, which doesn't work right away? Don't you just get totally irritated and think of the website as a bad one, because of that? How often do you think people experience the same thing on your own site? The "You know it already" bias Think about it... No matter how well you think your own site is, you should never forget about one important factor: You already know the website! You know where to find which information. You know which idea lies behind the menu structure. You know what happens where and why. However, which seems obvious for you or repetitive ...