six HTML heading tags

heading                  ::=      h1_tag
                         |        h2_tag
                         |        h3_tag
                         |        h4_tag
                         |        h5_tag
                         |        h6_tag

The heading rule tells us that wherever the heading nonterminal appears in a rule, you can replace it with exactly one of the actual heading tags.

text-shadow

Shadows are another common feature of modern Web designs. Shadows add an
element of depth to a page, but they can also enhance readability (if used properly)
to lift a headline from the page. The text-shadow attribute was technically
part of CSS2, but it has only recently been supported by major browsers:
h2 {
font-size: 300%;
text-shadow: 3px 3px 5px #666666;
}

Natural Link Acquisition

Nothing is better than natural link acquisition. This occurs when people who are genuinely
interested in your site link to it. Information travels fast on the Internet. As long
as your site is of great quality, you will reach a tipping point where it will no longer be
necessary to invest much effort in link building. This is something any site owner should
desire: having a site that is so infectious that it becomes the buzz.

P ARSING XML

Two techniques are used for parsing XML documents in PHP:
SAX(Simple API for XML) andDOM
(Document Object Model). By using SAX, the parser
goes through your document and fires events for every start and stop tag or
other element found in your XML document. You decide how to deal with the
generated events. By using DOM, the whole XML file is parsed into a tree that
you can walk through using functions from PHP. PHP 5 provides another way
of parsing XML: the SimpleXML extension. But first, we explore the two
mainstream methods.

We now leave the somewhat boring theory behind and start with an example.
Here, we’re parsing the example XHTML file we saw earlier. We do that by
using the XML functions available in PHP (http://php.net/xml
)
. First, we create
a parser object:
$xml = xml_parser_create('UTF-8');

xml_set_element_handler($xml, 'start_handler', 'end_handler');
xml_set_character_data_handler($xml, 'character_handler');

function start_handler ($xml, $tag, $attributes)
{
global $level;
echo "\n". str_repeat(' ', $level). ">>>$tag";
foreach ($attributes as $key => $value) {
echo " $key $value";
}
$level++;
}


DOM
Parsing a simple X(HT)ML file with a SAX parser is a lot of work. Using the
DOM (http://www.w3.org/TR/DOM-Level-3-Core/) method is much easier, but
you pay a price—memory usage. Although it might not be noticeable in our
small example, it’s definitely noticeable when you parse a 20MB XML file with
the DOM method. Rather than firing events for every element in the XML file.

<?php
 $dom = new DomDocument();
 $dom->load('test2.xml');
 $root = $dom->documentElement;

 process_children($root);

 function process_children($node)
 {
 $children = $node->childNodes;

 foreach ($children as $elem) {
 if ($elem->nodeType == XML_TEXT_NODE) {
 if (strlen(trim($elem->nodeValue))) {
 echo trim($elem->nodeValue)."\n";
 }
} else if ($elem->nodeType == XML_ELEMENT_NODE) {
process_children($elem);
     }
    }
   }
 ?>
The output is the following:
XML Example
Moved to
example.org
.
foo & bar

PEAR class: System

The System PEAR class is available as part of the basic PEAR install:
<?php
require_once "System.php";
$tmp_file = System::mktemp();
copy("http://php.net/robots.txt", $tmp_file);
$pear_command = System::which("pear");
?>
PEAR class: OS_Guess
The OS_Guess class uses the php_uname() function to determine on which
operating system it is running. It also provides ways of generalizing and comparing
OS signatures:
<?php
require_once "OS/Guess.php";
$os = new OS_Guess;
print "OS signature: " . $os->getSignature() . "\n";
if ($os->matchSignature("linux-*-i386")) {

print "Linux running on an Intel x86 CPU\n";
}
?>

Example output:
OS signature: linux-2.4-i386-glibc2.1
Linux running on an Intel x86 CPU

magic_quotes_gpc, magic_quotes_runtime

Magic quotes is the name of a PHP feature that automatically quotes input
data, by using the addslashes() function. Historically, this was used so that
form data could be used directly in SQL queries without any security or quoting
issues. Today, form data is used for much more, and magic quotes quickly
get in the way. We recommend that you disable this feature, but portable code
must be aware of these settings and deal with them appropriately by calling
stripslashes() on GPS (GET, POST, and cookie) data.

Website SWOT Analysis

A classic staple of business school is the SWOT analysis—identifying strengths, weaknesses,
opportunities, and threats faced by a business or project. By combining data from your business
asset assessment and historical tracking data (and visitor analytics), you can create some very
compelling analyses of your organization and its marketplace.
Identifying strengths is typically one of the easier objectives:

• What sources of traffic are working well for your site/business?
• Which projects/properties/partnerships are driving positive momentum toward traffic/
revenue goals?
• Which of your content sections/types produces high traffic and ROI?
• What changes have you made historically that produced significant value?
Sourcing out the weaknesses can be tougher (and takes more intellectual honesty and courage):
• What content is currently sending low levels of search/visitor traffic?
• Which changes that were intended to produce positive results have shown little/no value?
• Which traffic sources are underperforming or underdelivering?
• What projects/properties/partnerships are being leveraged poorly?

keys to getting links,

Since creating emotional reactions can result in links, building content that plays to the
emotions of potential linkers can be a powerful tool for obtaining links. Sometimes this
process is referred to as link baiting. One key decision for a business is whether such an
approach to link building is consistent with the company’s brand image, but even a
conservative brand can often find worthy link bait topics to be acceptable.

Create quality reference material. Providing unique and powerful information to users
can be a great way to get links, particularly if you can make sure the publishers of
authoritative sites in your market space learn about what you have created, including why
it would be of value to their website visitors.

 Leverage business relationships. In our example, we suggested that you might be someone
who has a network of resellers. If this is your business model, having a link back to you
as a standard term in your reseller agreement is sound business.

rel microformats

Remember the rel attribute from earlier? That attribute is often used in microformats,
and the usage is generally very simple. The rel-license format, for instance, looks like this:
<a rel="license" href="http://creativecommons.ca
/licenses/by-nc-sa/2.5/">
Creative Commons License</a>
By including a rel attribute with a value of license in the anchor tag, you can indicate
that the destination of the hyperlink is a license for the content contained on the current
page. The example I’m using is from my own design blog Unfortunately Paul, where the
content has been made available under a “Creative Commons Attribution-NonCommercial-
ShareAlike 2.5 License,” which means that people are free to copy, distribute, and display
my published entries and to make derivative works so long as I’m credited, it’s for nonprofit
purposes, and any derivations are released under the same license. Creative
Commons is an organization that provides a variety of “some rights reserved” copyright
licenses, allowing content authors to release their content into the wild but retain some
level of copyright.

Associative Arrays?

You can use string values as keys. For example, you might create an array
like this:

$myStuff = array();
$myStuff[“name”] = “andy”;
$myStuff[“email”] = “andy@fsdsd.ca”;
Print $myStuff[“name”];

Associative arrays are different than normal (numeric-indexed) arrays in
some subtle but important ways:
The order is undefined. Regular arrays are always sorted based on the
numeric index. You don’t know what order an associative array will be
because the keys aren’t numeric.

 You must specify a key. If you’re building a numeric-indexed array, PHP
can always guess what key should be next. This isn’t possible with an
associative array.

 Associative arrays are best for name-value pairs. Associative arrays are
used when you want to work with data that comes in name/value pairs.
This comes up a lot in PHP and XHTML. XHTML attributes are often in
this format, as are CSS rules and form input elements.

✦ Some of PHP’s most important values are associative arrays. The $_
REQUEST variable (described in Chapter 3 of this minibook) is an important
associative array. So are $_GET, $_POST, and several others.

Make sure to include quotation marks if you’re using a string as an array
index.