New

Hi everyone. I am starting a new project, building a website from scratch that I believe in time might help pay the bills.

I’m new to php and html and pretty much most programming.

I worked as an Oracle db engineer in the 90s, but I’ve forgotten most of that, as I’ve been in a different industry since then.

I’ve read some tutorials and whatnot, and have many questions I’ll be asking about php, html, jscript, ajax, et al. I’m using a VPS for development and have control over the Ubuntu OS.

If it ever pans out and I deploy it, I’ll probably use Amazon AWS. But this all could be a pipe dream, but I have some free time due to injury, and decided to create a website that might be helpful for some people and also generate me an income, no matter how small.

First question, I’ve coded a few web pages just as a test to begin, and it seems I use php and html code within the same file almost always. Should I save all the web files that combine html and php with a .php extension? Is there a reason for separating the html code from the php files?

The little I’ve written uses php to generate the html within the same file, depending on the situation, so it seems logical to save all files as .php and not have very many .html files, if any.

So I’m just wondering how you guys deal with extensions for your web page files. If .html extension files are needed, or if there’s a good reason to have .html files instead of using just .php all the time.

Thanks much.

Hi,

To start with your first question, I find it easier to keep files apart when they are labeled properly. If I get a PHP-error I know I don’t have to look through .html files. As soon as there is any PHP in the file I’ll label it as .php, even if it’s only writing values.

… but I’m only speaking for myself. Calling everything .php will work too.

Did that answer your question?
O.

Yes, thanks for the feedback Ojoshiro. Are you saying you don’t have any php and html code within the same file? Is that standard for most programmers you know, or just the method you find personally easiest?

Are there any drawbacks to naming everything with the .php extension?

Thanks again.

I am a noob, so don’t trust me word for word, but I label everything with .php. I just do. Even if it’s full HTML, you can label it with .php. As Ojoshiro said, you don’t have to look through .html files if you get a PHP error, though usually errors appear like this.

Unexpected ( on line 4 at C:/www/wamp/login.php

As you can see, it says what file the error is on, not to mention the line (in this case, line 4 on page login.php)

Well that’s how it works for my coding software, I don’t know if they’re all the same. Good luck!

Thanks MiniCoder. I’m using a linux OS, Ubuntu. I think I’ll do what you’re doing and go with .php extensions for html files, at least for now. If debugging becomes an issue as to finding the error, I’ll rethink it. I’m newer to this than you are, and have a long slog ahead of me, but I think I can handle it. I know I’ll be a frequent visitor to these forums. Good luck to you also.

I keep it all together, php and html together. I only seperate out css. For me, it makes it a lot easier when i have to troubleshoot something, plus it cuts down on the number of overall pages. But then again, i usually only have 1 main page (index.php) and all my other includes are just basic html/php.

it all comes down to what you’re trying to do and how you want to go about it. I wouldn’t try to put multiple pages in 1 file as pure code though, that’s a a pain the rump to troubleshoot and becomes a quick nightmare if you have to add more content down the line. Trust me, i’ve done it and i ended up redoing the entire site over again.

Thanks for the tips richei, appreciate it.

Sponsor our Newsletter | Privacy Policy | Terms of Service