Archive for October, 2007

1 on 1 web hosting - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY There

Wednesday, October 24th, 2007

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY There are two ways around this problem: Use double quotes if the text includes any apostrophes. Precede apostrophes with a backslash (this is known as escaping). So, either of the following is acceptable: $book[’description’] = “This is David’s sixth book on PHP.”; $book[’description’] = ‘This is David’s sixth book on PHP.’; The same applies with double quotes in a double-quoted string (although with the rules reversed). The following code causes a problem: $play = “Shakespeare’s “Macbeth”"; In this case the apostrophe is fine, because it doesn t conflict with the double quotes, but the opening quotes in front of Macbeth bring the string to a premature end. To solve the problem, either of the following is acceptable: $play = ‘Shakespeare’s “Macbeth”‘; $play = “Shakespeare’s “Macbeth”"; In the first example, the entire string has been enclosed in single quotes. This gets around the problem of the double quotes surrounding Macbeth, but introduces the need to escape the apostrophe in Shakespeare s. The apostrophe presents no problem in a double-quoted string, but the double quotes around Macbeth both need to be escaped. So, to summarize: Single quotes and apostrophes are fine inside a double-quoted string. Double quotes are fine inside a single-quoted string. Anything else must be escaped with a backslash. The key is to remember that the outermost quotes must match. There is more on this important subject in the second half of this chapter, including a technique that avoids the need to give special treatment to quotes. Special cases: true, false, and null Although text should be enclosed in quotes, three special cases true, false, and null should never be enclosed in quotes unless you want to treat them as genuine text (or strings). The first two mean what you would expect; the last one, null, means nothing or no value. Technically speaking, true and false are Boolean values. The name comes from a nineteenth-century mathematician, George Boole, who devised a system of logical oper- ations that subsequently became the basis of much modern-day computing. It s a com- plicated subject, but you can find out more at http://en.wikipedia.org/wiki/ Boolean_logic. For most people, it s sufficient to know that Boolean means trueor false.
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

HOW TO WRITE PHP SCRIPTS Understanding when to (Web hosting account)

Tuesday, October 23rd, 2007

HOW TO WRITE PHP SCRIPTS Understanding when to use quotes If you look closely at the PHP code block in Figure 3-1, you ll notice that the value assigned to the first variable isn t enclosed in quotes. It looks like this: $startYear = 2006; Yet all the examples in Using arrays to store multiple values did use quotes, like this: $book[’title’] = ‘PHP Solutions: Dynamic Web Design Made Easy’; The simple rules are as follows: Numbers: No quotes Text: Requires quotes As a general principle, it doesn t matter whether you use single or double quotes around text or a string, as text is called in PHP and other computer languages. The situation is actually a bit more complex than that, as explained in the second half of this chapter, because there s a subtle difference in the way single and double quotes are treated by the PHP engine. The word string is borrowed from computer and mathematical science, where it means a sequence of simple objects in this case, the characters in text. The important thing to remember for now is that quotes must always be in matching pairs. This means you need to be careful about including apostrophes in a single-quoted string or double quotes in a double-quoted string. Take a look at the following line of code: $book[’description’] = ‘This is David’s sixth book on PHP.’; At first glance, there seems nothing wrong with it. However, the PHP engine sees things differently from the human eye, as Figure 3-5 demonstrates. Figure 3-5. An apostrophe inside a single-quoted string confuses the PHP engine.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY You (Top ten web hosting)

Monday, October 22nd, 2007

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY You can learn the various ways of creating arrays in the second half of this chapter. PHP s built-in superglobal arrays PHP has several built-in arrays that are automatically populated with really useful information. They are called superglobal arrays, and all begin with a dollar sign followed by an underscore. Two that you will meet frequently are $_POST and $_GET. They contain information passed from forms through the post and get methods, respectively. The superglobals are all associative arrays, and the keys of $_POST and $_GET are automatically derived from the names of form elements. Let s say you have a text input field called address in a form; PHP automatically creates an array element called $_POST[’address’] when the form is submitted by the post method or $_GET[’address’] if you use the get method. As Figure 3-4 shows, $_POST[’address’] contains whatever value a visitor enters in the text field, enabling you to display it onscreen, insert it in a database, send it to your email inbox, or do whatever you want with it. Figure 3-4. You can retrieve the values of user input through the $_POST array, which is created automatically when a form is submitted using the post method. The main superglobal arrays that you’ll work with in this book are as follows: $_POST: This contains values sent through the post method. You’ll encounter it in most chapters, beginning with Chapter 5, where you’ll use it to send the content of an online feedback form by email to your inbox. $_GET: This contains values sent through a URL query string. You’ll use it frequently in Chapters 12 through 14 to pass information to a database. $_SERVER: This contains information stored by the web server, such as filename, pathname, hostname, etc. You’ll see it in action in Chapters 4, 12, and 13. $_FILES: This contains details of file uploads, which are covered in Chapter 6. $_SESSION: This stores information that you want to preserve so that it’s available to other pages. It’s used to create a simple login system in Chapters 9 and 15. Don t forget that PHP is case-sensitive. All superglobal array names are written in uppercase. $_Post or $_Get, for example, won t work.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

HOW TO WRITE PHP SCRIPTS Using arrays to (Web host 4 life)

Sunday, October 21st, 2007

HOW TO WRITE PHP SCRIPTS Using arrays to store multiple values In common with other computing languages, PHP lets you store multiple values in a special type of variable called an array. The simple way of thinking about arrays is that they re like a shopping list. Although each item might be different, you can refer to them collectively by a single name. Figure 3-3 demonstrates this concept: the variable $shoppingList refers collectively to all five items wine, fish, bread, grapes, and cheese. 3 Figure 3-3. Arrays are variables that store multiple items, just like a shopping list. Individual items or array elements are identified by means of a number in square brackets immediately following the variable name. PHP assigns the number automatically, but it s important to note that the numbering always begins at 0. So the first item in the array, wine, is referred to as $shoppingList[0], not $shoppingList[1]. And although there are five items, the last one (cheese) is $shoppingList[4]. The number is referred to as the array key or index, and this type of array is called an indexed array. PHP uses another type of array, in which the key is a word (or any combination of letters and numbers). For instance, an array containing details of this book might look like this: $book[’title’] = ‘PHP Solutions: Dynamic Web Design Made Easy’; $book[’author’] = ‘David Powers’; $book[’publisher’] = ‘friends of ED’; $book[’ISBN’] = ‘1-59059-731-1′; This type of array is called an associative array. Note that the array key is enclosed in quotes (single or double, it doesn t matter). It mustn t contain any spaces or punctuation, except for the underscore. Arrays are an important and useful part of PHP. You ll use them a lot, starting with the next chapter, when you ll store details of images in an array to display a random image on a web page. Arrays are also used extensively with a database, as you fetch the results of a search in a series of arrays.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY When (Web design templates)

Sunday, October 21st, 2007

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY When a script is fresh in your mind, it may seem unnecessary to insert anything that isn t going to be processed. However, if you need to revise the script several months later, you ll find comments much easier to read than trying to follow the code on its own. During testing, it s often useful to prevent a line of code, or even a whole section, from running. Because PHP ignores anything marked as a comment, this is a useful way of turning code on and off. There are three ways of adding comments: two for single-line comments and one for comments that stretch over several lines. Single-line comments The most common method of adding a single-line comment is to precede it with two forward slashes, like this: // this is a comment and will be ignored by the PHP engine PHP ignores everything from the double slashes to the end of the line, so you can also place comments alongside code (but only to the right): $startYear = 2006; // this is a valid comment Instead of two slashes, you can use the hash or pound sign (#). Because # stands out prominently when several are used together, this style of commenting is used mainly to indicate sections of a longer script, like this: ################## ## Menu section ## ################## Multiline comments If you want a comment to stretch over several lines, you can use the same style of comments as in Cascading Style Sheets (CSS). Anything between /* and */ is treated as a comment, no matter how many lines are used, like this: /* This is a comment that stretches over several lines. It uses the same beginning and end markers as in CSS. */ Multiline comments are particularly useful when testing or troubleshooting, as they can be used to disable long sections of script without the need to delete them. A combination of good comments and well-chosen variable names makes code easier to understand and maintain.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Best web hosting site - HOW TO WRITE PHP SCRIPTS The variable goes

Saturday, October 20th, 2007

HOW TO WRITE PHP SCRIPTS The variable goes on the left of the equal sign, and the value goes on the right. Because it assigns a value, the equal sign is called the assignment operator. Note that the line of code ends with a semicolon. This is an important point that I ll come to after this quick warning. Familiarity with the equal sign from childhood makes it difficult to get out of the habit of thinking that it means is equal to. However, PHP uses two equal signs (==) to signify equality. This is one of the biggest causes of beginner mistakes and it often catches more experienced developers, too. The difference between = and == is covered in more detail later in this chapter. 3 Ending commands with a semicolon PHP is written as a series of commands or statements. Each statement normally tells the PHP engine to perform a particular action, and it must always be followed by a semicolon, like this: As with all rules, there is an exception: you can omit the semicolon if there s only one statement in the code block. However, don t do it. Get into the habit of always using a semicolon at the end of every PHP statement. PHP is not like JavaScript or ActionScript. It won t automatically assume there should be a semicolon at the end of a line if you omit it. This has a nice side effect: you can spread long statements over several lines and lay out your code for ease of reading. PHP, like XHTML, ignores whitespace in code. Instead, it relies on semicolons to indicate where one command ends and the next one begins. Using a semicolon at the end of a PHP statement (or command) is always right. A missing semicolon will bring your page to a grinding halt. Commenting scripts PHP treats everything between the opening and closing PHP tags as statements to be executed, unless you tell it not to do so by marking a section of code as a comment. The following three reasons explain why you may want to do this: To insert a reminder of what the script does To insert a placeholder for code to be added later To disable a section of code temporarily
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Web space - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY Naming

Friday, October 19th, 2007

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY Naming variables You can choose just about anything you like as the name for a variable, as long as you keep the following rules in mind: Variables always begin with a dollar sign ($). The first character after the dollar sign cannot be a number. No spaces or punctuation are allowed, except for the underscore (_). Variable names are case-sensitive: $startYear and $startyear are not the same. When choosing names for variables, it makes sense to choose something that tells you what it s for. The variables you ve seen so far $startYear, $thisYear, $name, and $balance are good examples. Even if you don t understand how the code works, a variable s name should give some indication as to what it s about. Because you can t use spaces in variable names, it s a good idea to capitalize the first letter of the second or subsequent words when combining them (sometimes called camel case). Alternatively, you can use an underscore ($start_year, $this_year, etc.). Technically speaking, you can use an underscore as the first character after the dollar sign, but it s not a good idea. PHP predefined variables (e.g., the superglobal arrays described a little later in this chapter) begin with an underscore, so there s a danger that you may accidentally choose the same name and cause problems for your script. Don t try to save time by using really short variables. Using $sy, $ty, $n, and $b instead of the more descriptive ones makes code harder to understand and that makes it hard to write. More important, it makes errors more difficult to spot. Although you have considerable freedom in the choice of variable names, you can t use $this, because it has a special meaning in PHP object-oriented programming. It s also advisable to avoid using any of the keywords listed at www.php.net/manual/en/ reserved.php. Assigning values to variables Variables get their values from a variety of sources, including the following: User input through online forms A database An external source, such as a news feed or XML file The result of a calculation Direct inclusion in the PHP code Wherever the value comes from, it s always assigned in the same way with an equal sign (=), like this: $variable = value;
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

HOW TO WRITE (Web site design) PHP SCRIPTS solution saves you

Friday, October 19th, 2007

HOW TO WRITE PHP SCRIPTS solution saves you time in the long run. Instead of you needing to update the copyright statement every year, the PHP code does it automatically. You write the code once and forget it. What s more, as you ll see in the next chapter, if you need to amend the code, it s possible to do so by updating only one page, and the changes are reflected on every page of your site. This ability to display the correct year automatically relies on two key aspects of PHP: variables and functions. As the name suggests, functions do things; they perform preset tasks, such as getting the current date and converting it into human-readable form. I ll cover functions a little later, so let s take variables first. The script in Figure 3-1 contains two variables: $startYear and $thisYear. A variable is simply a name that you give to something that may change or that you don t know in advance. Variables in PHP always begin with $ (a dollar sign). Although the concept of variables sounds abstract, we use variables all the time in everyday life. When you meet somebody for the first time, one of the first things you ask is What s your name? It doesn t matter whether the person you ve just met is Tom, Dick, or Harry, we use the word name in the same way as PHP uses variables. The word name remains constant, but the value we store in it varies for different people. Similarly, with your bank account, money goes in and out all of the time (mostly out, it seems), but as Figure 3-2 shows, it doesn t matter whether you re scraping the bottom of the barrel or as rich as Croesus, the amount available at any particular time is always referred to as the balance. Figure 3-2. The balance on your bank statement is an everyday example of a variable the name stays the same, even though the value may change from day to day. So, name and balance are everyday variables. Just put a dollar sign in front of them, and you have two ready-made PHP variables, like this: $name $balance Simple.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

Web hosting ratings - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY You

Thursday, October 18th, 2007

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY You can have as many PHP code blocks as you like on a page, but they cannot be nested inside each other. Figure 3-1 shows a block of PHP code embedded in an ordinary web page and what it looks like in a browser and page source view after it has been passed through the PHP engine. The code calculates the current year, checks whether it s different from a fixed year (represented by $startYear in line 32 of the code on the left of the figure), and displays the appropriate year range in a copyright statement. As you can see from the page source view at the bottom right of the figure, there s no trace of PHP in what s sent to the browser. The only clue that PHP has been used to generate that part of the page lies in the whitespace between the date range and the surrounding text, but that doesn t affect the way it s displayed because browsers ignore anything more than a single space in XHTML. Figure 3-1. Output from PHP is normally displayed in the same place as it is embedded in the XHTML code. PHP doesn t always produce direct output for the browser. It may, for instance, check the contents of form input before sending an email message or inserting information into a database. So some code blocks are placed above or below the main XHTML code. Code that produces direct output, however, always goes where you want the output to be displayed. Using variables to represent changing values The code in Figure 3-1 probably looks like an awfully long-winded way to display a range of years. Surely it s much simpler to just type out the actual dates? Yes, it is, but the PHP
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

HOW TO WRITE PHP SCRIPTS A typical PHP (Best web design)

Wednesday, October 17th, 2007

HOW TO WRITE PHP SCRIPTS A typical PHP page will use some or all of the following elements: Variables to act as placeholders for unknown or changing values Arrays to hold multiple values Conditional statements to make decisions Loops to perform repetitive tasks Functions to perform preset tasks Let s take a quick look at each of these in turn. Telling the server to process PHP PHP is a server-side language. This means that the web server processes your PHP code and sends only the results usually as XHTML to the browser. Because all the action is on the server, you need to tell it that your pages contain PHP code. This involves two simple steps, namely: Give every page a PHP filename extension the default is .php. Do not use any thing other than .php unless you are told to specifically by your hosting company. Enclose all PHP code within PHP tags. The opening tag is . It doesn t matter whether you put the tags on the same line as surrounding code, but when inserting more than one line of PHP, it s a good idea to put the opening and closing tags on separate lines for the sake of clarity. You may come across tag. If the PHP code produces any output, it s inserted at that point. Then any remaining XHTML passes through until another Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.