Oct
14
2008
0

Why use an array?

Recently, I asked myself the same question.  You might be wondering, what is an array.  According to Wiki:

In computer science an array [1] is a data structure consisting of a group of elements that are accessed by indexing.

What does that  really mean?  Well, I’ll explain by using an example I got off one of the programming forums I frequent, SamponVideos.com. I will actually quote some of Johnathan Sampson’s message because it captures the idea.  In his example, if you were creating a an image uploader, and you did not want to allow executable files, you would do something like this:

$fileTypes = array("jpeg","gif","jpg","bmp");

Without the use of an array, it would turn into this:

if ($fileExtension == “jpeg”) {
# Approved
} else
if (
$fileExtension == “gif”) {
# Approved
} else
if (
fileExtension == “jpg”) {
# Approved
}

Or this:

if ($fileExtension == “jpeg” || $fileExtension == “gif” || $fileExtension == “jpg”) {
# Approved
}

The array makes the code, much easier to handle, and looks cleaner.  Have you used arrays in your projects?

Written by Bryan in: PHP Script | Tags: , , , ,
Jul
10
2008
0

Easy Site-Wide Link Updating

As I have created more websites, I have come to love includes.  They are useful when you need to use one file repeatadly.  For instance, you may want the same navigation scheme across a site.  It would be troublesome, or bothersome to insert you navigation code on each page.

What happens when you add or subtract a page? You would have to change every single page.  9 times out of 10, you always miss at least one page.  There are other situations where using an include would come in handy, but those are more programming oriented.

You will need:

  1. PHP (in this case), or ASP based server
  2. Main Page
  3. Navigation Page

This code requires the use of PHP, on the main page you need  to write, and so this page must end in .php, for example, index.php.  The ending php tells your server it needs to do more work with that page before displaying it.

Whenever you are using a PHP tag, you must enclose it in

<?php **Place Code Here** ?>

On the every page you want this content to appear insert the code:

<?php include(”file directory here/link.html”);  ?>

This tells the server to include “file.html” in that place on the page. Now, you create “link.html”.

<ul>
<li><a href=”index.php” title=”Home”>Home</a></li>
<li><a href=”contact.php” title=”Contact Us”>Contact Us</a></li>
<li><a href=”location.php” title=”Location”>Location</a></li>
</ul>

Now upload these pages to your webserver and only update “link.html” as needed.

Written by Bryan in: PHP Script, Uncategorized | Tags: , , ,
Jun
12
2008
0

Automatic Copyright Updating


Many people who design websites put copyright dates on every page of their website.  By inserting this snippet of code your site will bringing in the new year with an up to date copyright date.

Today this snippet will output Copyright 2008 Resnodesigns and next year, it will greet the New Year with Copyright 2009 Resnodesigns.


Copyright <? echo date("Y"); ?> Resnodesigns
Written by Bryan in: PHP Script | Tags: , ,
Feb
15
2008
0

What are PHP and ASP.net?

Recently, I have been having alot of questions about what PHP and ASP.net are and how do they help on a site.

What are PHP and ASP.net? Why do I care?

1. What are PHP and ASP.net?

1. Well, when you want to use a shopping cart, forum, or anything outside of a static website it requires the server to do something. For example, this blog is written in PHP, because I can add blogs and I do not have to edit the html code.

2. What’s the difference between PHP and ASP.net?

1. PHP generally is used by people like us, who design and build websites.

2. ASP.net is generally used by big corporations. They like ASP.net because it is backed and supported by Windows.

3. Now, why do you care?

1. Does your business want to sell products online?

2. Do you want a forum or other social networking system? (Facebook, Myspace, YouTube, etc.)

3. These types of sites require the server to handle parts of your site because html can not do it alone.

 

Written by Bryan in: Hosting | Tags: , , , ,

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes