My Friend,
I will take you down the alley where you live and help you understand what PHP, HTML, CSS and JavaScript are all about. I must mention here though that I will be simplifying the answer of Sir SA Kryukov.
So friend, Let's have a look at HTML :
1. A Markup Language (Built using tags): The tags are parsed in the browser and browser actually displays the objects, format it, color it etc. (That's Why each browser displays the same page slightly different.
2. HTML is used for layout definition of a webpage (not a website: its a collection of webpages linked together via hyperlinks and are stored on a single machine (generally)).
3. Via HTML you create the front-end of your website. You define, the header, footer, body, navigation, sidebar etc via HTML.
4. HTML support addition of non-html content to be added also via some tags like <script> tag is used for javascript, <style> tag is used to define CSS
Now, We will talk about CSS :
1. CSS (Cascading Stylesheet): It is actually you can say language, for styling the layout that you have defined via HTML.
2. You can directly style a particular tag globally For example :
a { background: #00eeee; }
will make all the hyperlinks of the webpage to have a background of yellow.
3. You can also style a particular tag that itself is encapsulated inside another tag. For example: If you want to make all the
<p>
tags to have a font-family of "Verdana" which are lying inside a
<span>
tag; you can write
span p { font-family: "Verdana" }
4. You can also target a particular group or a completely unique element using class (for group) and ID (for unique individual) and style them independently.
Now, enough about HTML and CSS. Both are Static to themselves but, when you want to generate a page which is actually generated at the time a user has requested it like a search result or a particular post on a blog. Then?
Well Friend, here comes the world of scripting languages. Scripting languages are like any other language like C, C++ etc but the difference is that these are web development languages.
There are basically two types of scripting. These are :
1. Server-Side Scripting : Example PHP, ASP, ASP.Net, JSP etc
2. Client-Side Scripting: Example Javascript
Now, let us talk about PHP.
PHP is a server-side scripting language. By scripting language, I mean that you can use this language to define your own logic. Thus, you can do some work based on the condition that satisfies. Examples are :
if-else
,
switch-case
etc; or, you can loop through a particular block of code to realize a repetitive work without much code. Examples are :
while
,
do-while
,
for
,
foreach
.
Being, a server -side scripting language, it is run only on server side. That implies that, No part of code is executed on client side, the whole script is executed on server side and it's result is transferred via a web server to client side.
Now, the benefit of this technique is that you can generate HTML codes based on some conditions or generate a repetitive HTML block using Loop etc. Thus, I can generate a search result page. Wherein, I have a variable that has stored all the search result and I can loop through it and display all the content. Moreover, I will also add HTML tags along with the response, so the result of the whole script parsing at server will generate simply a pure HTML (in fact a pure binary. You can set it's mime-type to make it behave like anything thereby making it deliver any content even images or videos can be transmitted not just HTML Cool right?).
Now, Your question: You wanted to add stylesheet to your page that you had generated via PHP. Now, that you know, how PHP is working and what actually is it doing, you know, that similar to a normal HTML page, you have to write the
<link rel="stylesheet" href="global.css" type="text/css" />
in the php echo inside the part where you have echoed the
<head>
tag since
<link>
tag is put in the
<head>
tag.
this is a simple code :
I can mix HTML and PHP too. The PHP part is always put inside a
<?php ?>
tag block while HTML can be put anywhere. If you have to put HTML inside the
<?php ?>
tag block. Then you actually have to print it using either print or echo function.
<html>
<head>
<title>Test</title>
<style type="text/css">
p {
font-face: "Verdana";
}
</style>
</head>
<body>
// This is a comment
$message = "Hello World"; // This is a variable in PHP. Its value is Hello World
echo '<p>'.$message.'</p>'; // Here the result of this operation is <p>Hello World</p>
?>
</body>
</html>
Hope that this complete explanation helped you. Took me 1/2 hrs to type :P Please do rate it and mark it as solved if it solved your problem.
With Regards
Tushar Srivastava