Beruflich Dokumente
Kultur Dokumente
Cascading Style Sheets let you control the display characteristics of your web site. In
CSS, style rules express the style characteristics for an HTML element. A set of style
rules is called a style sheet. A style rule is composed of two part: a selector and a
declaration. The style rule expresses the style information for an element. The selector
determines the element to which the rule is applied. The declaration details the exact
property values.
Style rule syntax
h1{color:red;}
The value text/css defines the style language as Cascading Style Sheets. Although not
required, the type attribute should always be included in all of your <style> elements for
future compatibility.
The <link> element in the example tells the browser to find the specified style sheet. The
href attribute states the relative URL of the style sheet. The rel attribute specifies the
relationship between the linked and current documents. The browser displays the web
pages based on the CSS display information. The advantage of the external style sheet is
that you can state the style rules in one document and affect all the pages on a web site.
When you want to update a style, you only have to change the style rule once in the
external style sheet.
1. The class attribute lets you write rules, give them a name and then supply that name to
any elements you choose. You can use class with any HTML element because it is a core
attribute. The core attributes are id, class, style and title and they apply to all HTML
elements. To apply a style rule to an element, you can add the class attribute to the
element and set it to the name you have specified. To create a class, declare a style rule.
The period (.) flag character indicates that the selector is a class selector
Ex. .test{color:blue; margin:30px;} //class name is test
The class attribute lets you select elements with a greater precision.
Ex. p{font-size:.85%;}
The example rule above set all <p> elements in the document to a font size of 85%. You
can then create a class that can be applied to a particular <p> element.
Ex.
.special{font-weight:bold; font-family:sans-serif;}
To apply the class to a <p> element:
<p class = special>This text is will have a different style compared to the next one</p>
<p> The text here has no class attribute defined and is therefore different compared to the
text where a class named special is applied</p>
2. Using the id attribute selector
The id attribute, like the class attribute is an HTML core attribute. The difference
between id and class is that id refers only to one instance of the id attribute value within
a document. This allows you to specify an id value and apply it to one unique element in
a document.
Ex.
#preface{font-weight:bold; font-size:125%;} //id name is preface
The id selector uses a # sign flag character instead of the period(.) used in the class
selector. You can then apply the id value to the appropriate element in the document
Ex.
<p id=preface>The text here is applied with the preface id attribute</p>
Displaying Errors
PHP can be set to give you feedback if it encounters problem. Whether it does so is
based on the display_errors setting in PHPs configuration file(php.ini) In current
versions of PHP, this setting is disabled so errors generated by a script result in a blank
screen.
To have PHP display errors, you can turn display_errors back on for a particular script
Ex. ini_set(display_errors,1);
Error Reporting
PHP Error types
Type Description Example
Notice Nonfatal problem that may or may not be Referring to a variable that
indicative of a problem has no value
Warning Nonfatal error that is most likely problematic Passing the wrong type of
parameter to a function
Parse Fatal error caused by a syntactical mistake Omission of a semicolon or
error an imbalance of quotation
marks, braces or parenthesis
Error A general fatal error Memory allocation problem
You can determine what errors PHP reports on using the error_reporting() function. The
function takes either a number or a constant(a nonquoted string with a predetermined
meaning) to adjust the levels
Ex. error_reporting(0); //turn off entirely
error_reporting(E_ALL); // Report everything
eror_reporting(E_ALL & ~E_NOTICE); //see all errors messages except notices
Using Constants
Constants are specific data type in PHP. Unlike variables, they retain their initial value
throughout the course of a script. You cant change the value of a constant once it has
been set. To create a constant, you use the define()
Ex. define(CONSTANT_NAME,constant_value)
define(TITLE,Welcome to My Home Page);
By convention, constant names are written using capital letters and they do not use $ like
ordinary variables. Constants cannot be printed using single or double quotation marks as
in : printTitle is TITLE ;
or print Title is TITLE;
output
Today is August 09,2010
It is now 01:30:15 pm
Using isset()
To determine if the form has been submitted, you can check whether the submit variable
is set (which means the submit button has been clicked). To make a page both display
and handle a form, use a conditional:
if( isset($_POST[submit]))
{//handle the form }
else
//display the form