When you’re running a PHP program on your own machine, using the command
line, as soon as you’ve saved your PHP you can run it. But when you’re working with
web pages and web applications, things are a bit trickier.
When you’re building a web page, you have to upload your HTML, CSS, and any
JavaScript you’ve written to your own web server. Then, you access those files with
a browser, through a web address like www.yellowtagmedia.com/sayHello.html.
Typing that web address into your browser causes your server to supply your HTML
to whatever web browser requested the page.
PHP works the same way. Once you’ve written your PHP programs, you upload
them onto your web server with your HTML and CSS. Typically, you’ll end up with
files and directories like the following:
• Root or home directory (/). Your web root, where you put all your HTML. This
usually is the location referenced by a URL like yellowtagmedia.com/, without
any specific file after the web server name.
• CSS directory (css/). The directory where all your site’s CSS is stored.
• JavaScript directory (js/). Your JavaScript files go here. You’ll often see this
directory also called scripts/, but since PHP programs are also called scripts,
it’s a good idea to be more explicit in your naming.
• PHP directory (scripts/). Here’s where you put all your PHP programs. Again,
you could call this something more specific like php/ or phpScripts/, but more
often than not, websites use scripts/ for this directory, so following that lead
is a good habit to get into.
• Examples directory (ch01/, ch02/, and so forth). As you’re working through
the examples, you’re going to end up with a lot of PHP programs, and fast.
To keep everything organized, you should have a separate directory for each
chapter. So when you upload sayHello.html and sayHelloWeb.php, upload them
into ch01/sayHello.html and ch01/scripts/sayHelloWeb.php.
line, as soon as you’ve saved your PHP you can run it. But when you’re working with
web pages and web applications, things are a bit trickier.
When you’re building a web page, you have to upload your HTML, CSS, and any
JavaScript you’ve written to your own web server. Then, you access those files with
a browser, through a web address like www.yellowtagmedia.com/sayHello.html.
Typing that web address into your browser causes your server to supply your HTML
to whatever web browser requested the page.
PHP works the same way. Once you’ve written your PHP programs, you upload
them onto your web server with your HTML and CSS. Typically, you’ll end up with
files and directories like the following:
• Root or home directory (/). Your web root, where you put all your HTML. This
usually is the location referenced by a URL like yellowtagmedia.com/, without
any specific file after the web server name.
• CSS directory (css/). The directory where all your site’s CSS is stored.
• JavaScript directory (js/). Your JavaScript files go here. You’ll often see this
directory also called scripts/, but since PHP programs are also called scripts,
it’s a good idea to be more explicit in your naming.
• PHP directory (scripts/). Here’s where you put all your PHP programs. Again,
you could call this something more specific like php/ or phpScripts/, but more
often than not, websites use scripts/ for this directory, so following that lead
is a good habit to get into.
• Examples directory (ch01/, ch02/, and so forth). As you’re working through
the examples, you’re going to end up with a lot of PHP programs, and fast.
To keep everything organized, you should have a separate directory for each
chapter. So when you upload sayHello.html and sayHelloWeb.php, upload them
into ch01/sayHello.html and ch01/scripts/sayHelloWeb.php.
No comments:
Post a Comment