|
|
For local testing of .php files. Nothing fancy or complicated if you please.
|
|
|
I use WebFaction - multiple domains and websites on a single account - ideal for testing but can be slow at times.
P.S. Just realised - you seem to be asking for Windows hosting. Why don't you install Apache on your PC? XAMPP will install Apache, MySQL and PHP on Windows dead easy.
__________________________________________________________________________________________
"Windows Vista Sir?"
"No thanks, I'd rather shove wasps up my nostrils!" .
Mick's Blog | Greasemonkey scripts
Edited by micksharpe (Tue 23-Nov-10 11:12:17)
|
|
|
|
Do you mean a host or a package for installing locally or the spec of hardware to run it on?
|
|
Register (or login) on our website and you will not see this ad.
|
|
|
I mean a program that can be installed locally jsut to test php files locally, rather than upload them to a remote server to see if they work.
Free software btw.
|
|
|
Download and install XAMPP - job done.
__________________________________________________________________________________________
"Windows Vista Sir?"
"No thanks, I'd rather shove wasps up my nostrils!" .
Mick's Blog | Greasemonkey scripts
|
|
|
Ta for that.
A little chunky at 51MB download and 230 Meg installed, but it does do the job. What's more, my php files work!
|
|
|
Slight problem with the .php files calling on other files.
I have index.php, header.php and footer.php in the main folder, then have the css in a folder called 'css' and the images in a folder called 'img'.
Now the page works fine using relative paths (e.g. the header calls on "css/main.css"). However, if I create another .php file and put it in a new folder (e.g. test), I would call on the header and footer via:
<?php include '../header.php'; ?>
This works, but for some reason the css and images that the header calls don't work. It's as if they aren't being correctly 'pathed'.
My options seem to be:
Create a css and img folder for each sub folder which hold .php files, which defeats the whole point.
Keep all my .php files in the root folder.
Use absolute referencing (not keen on that, as it adds to file size, and makes changes more in depth).
Or am I doing something wrong?
One other thought.
Once I get the files created, I'll almost certainly want to have the title and meta tags within the head section different for each page. What's the best way to do this, given that my current global header calls from the Doctype declaration down to the first heading in the main body?
|
|
|
When you use the include command, it calls the file and adds it to the php script that is being run, so the relative paths in the header and footer files will be interpreted as if they are from the test file.
So for example, on my web server the header and footer files are in the parent folder of the web root folder. The relative links however are written as though they are in the web root folder. This works because of how php interprets them.
Basically you need to place all the php files that use the same CSS and image files in the same folder.
As to changing aspects this can be done easily by asigning a variable and then calling the header.
eg
| Text | 1
23
4 | <?php
$page = test;include '../header.php';
?> |
Then you can reference this within the header file for all the attributes you wish to change.
It would be best to do so with a switch statement.
|
|
|
you could call the css using the following code:
<link href="/css/style.css" rel="stylesheet" type="text/css" />
The leading / makes it start from the web root so it works regardless of what directory the php fileis in.
Edited by deleted (Wed 24-Nov-10 11:09:14)
|
|
|
Ahh, spot on!
I had dumped all the files into a sub-folder, so needed to have as /subfolder/css/main.css, rather than /css/main.css
I forget about the 'root' folder aspect of things. Too used to windows.
Ta very much!
|
|
|
Still getting problems due to some files being on different levels to the index.php (thus the calling of the header, and thus the css is wrong).
It occurred to me that all of my pages will use 'header.php'. Equally, I only plan to have one stylesheet, so I'm wondering if it would be easier all round if I include the css code in the head section of header.php
In that sense, there would be no stylesheet, and one less http request. The argument for a stylesheet is that the called for file gets cached. I assume the header.php with the style code would get cached too?
|
|
|
Right. Tis fixed.
The Apache server created a folder called xampp within htdocs. I had dumped all my design pages into this folder, so was not operating from the root folder.
Since moving all to root, all I had to do was add some ../ code to each image line to ensure all relative links moved to root before progressing down their path.
Still not sure whether it's a good idea to keep the css in the header.php or not. One could argue that if header.php were to fail, then I'd lose navigation and styling. That's the only drawback as far as I can see.
|
|
|
There is a way to do this with php using:
| Text | 1
| $_SERVER["DOCUMENT_ROOT"]; |
I can check this out at home (I have used it on another website), but basically (I think) it sets the path that your html is in so you can easilly go back and forth using relative links...
|
|
|
Yes, I spotted that in my php googling, but have never used, so was a little unsure of it.
I might look into it later on. Now that my paths are working, I'm keen to move onto other aspects for now. It's definitely one to ponder on before going live.
|
|
|
There are endless possibilities on how you can organise your code and I am unsure how you are doing yours. When I look back at the coding I did when I first started learning php I am somewhat horrified. Even in the beginning I used templates but I used to cram all sorts into it and still ended up duplicating code (and that defeats the point of templates!).
I still only code php for my own interest really but now I have torn to pieces part of a site I was working on a while ago and use that now as a basis for my coding and I also use smarty which is a template engine that seperates your php and html code.
Nowadays some of my php pages are tiny:
| Text | 1
23
45
67
89
10 | <?php
include_once("include_files.php");
//load templates
$smarty->display(TEMPLATE_SITE_LAYOUT);$smarty->display(TEMPLATE_INDEX);
$smarty->display(TEMPLATE_SITE_FOOTER);
?> |
Each page calls include_files.php which defines where everything is and in turn includes many other files. By the time a page has displayed my script will have easily accessed over 20 php files and 3 template files
If my 'header' files failed then the whole site would fail but I can't think why it would just fail and losing css is generally an irrelevance to whatever else stops working
|
|
|
Do you find that increased requests decrease response times at all?
|
|
|
No, well certainly nothing perceivable. If you were to look at any CMS (joomla, drupal etc.) or something like phpbb you will see that they all use millions of files all over the place. My setup is very similar to phpbb - i do wonder if someone stripped that down for the site I worked on... and I then took it and stripped it down further! So, I imagine that many people who are more knowledgable than me and create professional products seem to think it has no effect on performance but can lead to much more efficent coding (as long as you remember where everything is!  ).
Edited by deleted (Thu 25-Nov-10 14:30:38)
|