Generating a Randon Number in PHP

August 21, 2008

Sometimes you requirement to create unequalled randon drawing if you poverty to distribute IDs to your members or distribute unequalled values to your shopping cart items. Here I’m meet citing to think whereas it depends on you for what determine you’d same to create a haphazard sort in your PHP scripts. I hit cursive a diminutive duty that takes digit argument. This discussion tells the duty how some digits you poverty in the generated number.

For a springy warning of the article, go to
http://www.aboutwebdesigning.com/2005/09/29/generate-a-random-number-using-php

First, here’s the function:

function random_num($n=5)
{

return rand(0, pow(10, $n));
}

If you beam no discussion to the random_num() function, it generates a 5-digit haphazard number. This is how we ingest it:

echo random_num(); gave 96161 when proven and
reflexion random_num(7); gave 5983582 when tested

This duty uses the PHP science duty pow() to intend the sort of digits we want. The duty pow() calculates the noesis of a sort same feature 10 upraised to the noesis 5. In science we indite it same 10 Exp 5. Basically, the actual rand() duty takes 2 arguments: the modify bounds and the bunk limit. So if you poverty to create a haphazard sort that should be greater than 107 and inferior than 5067, you strength intend somethin like:

echo rand(107, 5067); gave 3456 when tested

Since we ordinarily don’t requirement the bunk limits and the modify limits, I’ve elucidated a generic duty that gives you a haphazard sort of spedicif sort of digits.

Amrit Hallan is a worker copywriter,
and a website noesis writer. He also dabbles
with PHP and HTML. For more tips and tricks in
PHP, JavaScripting, XML, CSS artful and
HTML, meet his journal at
http://www.aboutwebdesigning.com
วิธีทำ SEO



PHP Redirect

August 21, 2008

A PHP Redirect automatically transfers a scheme individual from digit address to another. For example, typewriting foo.com in the application automatically transfers the individual to added address bar.com.

The PHP Redirect command:

Replace [some-url] with the address where you poverty the redirection to verify place.

For example,

header(“location: ./version2/index.html”);
=>redirect to “index.html” tender in subfolder titled “version2″

header(“location: http://www.yahoo.com”);
=>redirect to a website titled yahoo.com

If PHP is not available, it’s also doable to ingest another redirects:

* protocol Redirects

Replace [time] with seconds. This module disrupt the application for the given sort of seconds. Replace [some-url] with the direct address you poverty to redirect.

For example,

The above protocol supported direct needs to be in the location of the HTML code.

* JavaScript Redirects

setTimeout(“location.href=’[some-url]‘”, [time]);

Replace [time] with milliseconds. This module disrupt the application for the given sort of seconds. Replace [some-url] with the direct address you poverty to redirect.

For example,
setTimeout(“location.href=’http://www.yahoo.com’”, 5000);

The above JavaScript supported direct crapper be either in the or location of the HTML code.

Usually a PHP direct is such more sure than another add of redirects same protocol direct or JavaScript supported redirects. For warning a JavaScript direct haw not impact if a user’s application settings has JavaScript overturned off.

The think ground PHP redirects module impact no concern what settings users hit on their application is because PHP is computer lateral script. It module not depend on application settings that haw change JavaScript which is parsed on the client-side/user-side.

About the Author

Sanjib Ahmad, Freelance Writer and Product Consultant for http://www.marc8.com.

You are liberated to ingest this article in its completeness as daylong as you yield every course in place, do not add the content, and allow the inventiveness incase traded above. เทคนิค SEO


Sending Email with PHP

August 21, 2008

A Contact Us tender with a HTML modify to occurrence the webmaster adds a pleasant individualized contact to some website. Users see “connected” to the someone and it makes them seems more down-to-earth.

PHP comes with a accessible duty called, would you conceive it, mail(). Here you module see how to ingest it in it’s most ultimate modify to beam a base email.

Please state that if your computer doesn’t hit PHP installed, this module not work. That effectuation Google-Pages too.

Now, to intend started. Instructions are presented in the comments.

Save the mass as sendEmail.php


PHP, SEO, and Spiders – Oh My!

August 21, 2008

Dynamic database-driven sites have become very popular, and relatively easy to set up and administer, through the use of Content Management Systems (CMS) and PHP server-side scripting. It’s also possible to create a fancy-looking site with little actual content, or automatically generated code that can harm your SEO, such as multiple URLs that display identical content.

Search engines are constantly evolving and adapting in response to changes in the way information is presented on the web. Strategies that were once necessary to ensure inclusion of PHP pages are no longer required.

It was once helpful to generate a static HTML version of a PHP page so that all the “includes” could be indexed. Now search spiders “see” all the content on a PHP page, the same way it is viewed in a browser.

It used to be prudent to avoid dynamic URLs containing “? & =” – now, the search engines list URLs with the dynamic variables. However, it is best to compose them with no more than three variables. Some variable-laden URLs may be listed, but without any accompanying content/description, in the search results… Stay tuned for further developments as the search engines refine their methods.

——

With many hosts running the popular Apache server, developers are expanding the use of PHP by modifying the .htaccess file to allow PHP code processing within HTML documents, and enabling shorter URLs with fewer variables by configuring httpd.conf. Your web hosting provider’s support team should be able to tell you if these features are available for your site.

Implementing a common-sense approach to SEO for your PHP site requires cooperation and coordination among the developer, webmaster, and web host. Beware of “SEO Experts” with “secret methods” and “guaranteed results” – gimmicks that kludge the search spider today might hurt your ranking tomorrow.

A descriptive and catchy page title is one of the key elements of SEO – whether or not your site uses PHP – since it becomes the linked title of your search engine listing. Use the name of your site in the title to encourage branding, along with a brief capsule about the specific page. Remember that the title displays at the top of the browser window and in the menu bar, so keep it brief, less than 160 characters. Avoid using identical titles on multiple pages (this can easily happen with dynamically generated titles) because they may not be listed individually, and if they are listed separately, it’s confusing. Meta tags for description and keywords have become less crucial to SEO – but that doesn’t mean you should forget about them.

The basic principles of SEO that apply to static HTML sites also apply to dynamic PHP sites:

● Provide engaging and valuable content presented in an attractive design.

● Code should be error-free and standards-compliant.

● Use keywords appropriate to your subject matter – don’t be tempted to use “tricks” that might end up hurting your search engine listing.

● Encourage repeat visits with frequent updates, interactive features, membership sign-up, opt-in newsletters and, if appropriate, “freebies” – contests, giveaways, downloads and other resources.

● Encourage linking to your site with copy & paste code. Reciprocal links build partnerships and enhance page rank, but avoid hosting bulky “link farms” and other venues for worthless web site spam.

● Make use of tools provided by the search engines, such as creating a sitemap.

● Educate yourself by reading the search engine faqs, as well as by perusing some independent forums for SEO tips and methods.

Here are a few resources for further information:

Optimizing Dynamic Content
http://www.highrankings.com/issue065.htm#seo

Building Dynamic Pages With Search Engines in Mind
http://phpbuilder.com/columns/tim20000526.php3

High Rankings(r) Search Engine Optimization Forum > Technobabble > Dynamically Generated Site Issues
http://www.highrankings.com/forum/index.php?s=c5e371a3bec60ac7e650447c430abfd4&showforum=25

Digital Point Forums > Marketing > Search Engine Optimization > PHP, HTML does it matter?
http://forums.digitalpoint.com/showthread.php?t=53280

Parsing PHP in .html Files
http://www.desilva.biz/php/phpinhtml.html

Article Source: http://www.a1-optimization.com/articles

—-

Ian Wilson is a support analyst, specializing in coding and system administration, for Apollo Hosting. Apollo Hosting provides website hosting, ecommerce hosting, vps hosting, and web design services to a wide range of customers.