WAMP Localhost not working

If you’ve installed WAMP and are getting a blank page when you try to browse to a page on a localhost….

Ask yourself one question….have you skype running? Skype uses port 80 to connect to the internet which your apache server also requires. So just turn skype of, retart wamp server and you should be good to go.

How to convert a string to an enum type in C#

Its quite easy and fairly handy and saves you having to use switch statements. You just need to use Enum.Parse. Below is an example.

Your enum:

private enum SortColumn { InitialRate = 1, Duration, SubsequentRate, OverallRate, MaxLTV }

The variable to store the enum type:

SortBy sort;

And the conversion of the string  sortString to your enumeration:

sort = (SortColumn) Enum.Parse(typeof(SortColum), sortString, true);

Master pages in PHP

One of the good things about  .NET is that you can you use master pages. A master page is basically a template page which you can use to control the layout of other pages. Its usefull to ensure consistency across all pages on a site and most importantly it cuts down on a lot of repetitive programming.

PHP does not support such a feature but its easy enough to achieve the same effect. The way I do this is by creating a PHP page called master.php. I fill out the HTML parts as normal and in the place which I want to have varying content between pages, I add PHP variables.

When implementing the inheriting pages later I define the same variables but also assign content to them. After the variables have been assigned content html, I import my master.php page.  Nice.

Here is an example:

The master page, Master.php

<html>

<head>..</head>

<body>….

<div id=”middle”>
<div id=”middleLeft”><?php echo $text; ?></div>
</div>

</body>

</html>

An a content page, about.php:

<?php ….

$text = “This is a good example”

include(“master.php”); ?>