advantages of using php instead of html

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 6217 Views - Last Post: 29 August 2011 - 05:53 PM Rate Topic: -----

#1 dbeaird727  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 238
  • Joined: 13-December 10

advantages of using php instead of html

Posted 26 August 2011 - 09:56 PM

What are the advantages of using php instead of html to code userbased web pages? Maybe they cant be built without it? I'm not sure i guess my next qustion would be... if i have a htmlbased webpage at the moment what would be the easiest way to convert that web page to phpbased? if this makes any sense at all.
Is This A Good Question/Topic? 0
  • +

Replies To: advantages of using php instead of html

#2 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

Re: advantages of using php instead of html

Posted 26 August 2011 - 10:08 PM

To build a website with user interaction, Php would in most cases be required. There are some great tutorials for using html with php. It is also good practice to separate you html code, from you php code.

How much of Php do you know?

This post has been edited by aaron1178: 26 August 2011 - 10:08 PM

Was This Post Helpful? 0
  • +
  • -

#3 thephpdev  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 59
  • Joined: 01-July 11

Re: advantages of using php instead of html

Posted 26 August 2011 - 10:21 PM

Advantages are:
# Less Websites to manage
# Easier to maintain

Cons are:
# Slightly slower (Depending on the size of the website)
Was This Post Helpful? 0
  • +
  • -

#4 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:07 AM

*
POPULAR

PHP and HTML are two completely separate things that are used together to build a website. You can't just use PHP to build a website - simple as.

Anyway, if you have an existing base and would like to make it easier to update using PHP, you can quite simply split it out, on a first level, to use a header/footer.

I have a tutorial here which should help you out with the basics.

If you're not just looking to make your site easier to update, then what is the purpose? I mean, are you looking for some form of interactivity by adding PHP, orrrr?!
Was This Post Helpful? 8
  • +
  • -

#5 dbeaird727  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 238
  • Joined: 13-December 10

Re: advantages of using php instead of html

Posted 27 August 2011 - 06:24 AM

Yes, I have a very basic webpage consisting of a home page with a form that will need submitted and then another page that will just act as a mini profile so that people can log in to see what info was submitted to them. I have done a little with php and a lot with html and css. I guess I am just trying to learn how to use the two together so that people can loggin, submit forms, etc.

I used a cms on a lot of my sites which i believe hindered my abilities :/ because it was more or less just editing code that was already there which in my eyes is much easier than building from scratch which im attempting to do now.
Was This Post Helpful? 0
  • +
  • -

#6 RudiVisser  Icon User is offline

  • .. does not guess solutions
  • member icon

Reputation: 1003
  • View blog
  • Posts: 3,562
  • Joined: 05-June 09

Re: advantages of using php instead of html

Posted 27 August 2011 - 06:31 AM

Yes using a CMS isn't a good idea if you're trying to learn how to do something, no.

If you're looking to make your site more dynamic you should first read a few PHP/MySQL tutorials and build a login system that's standalone from your website. When you're confident enough that you know how to build a reliable system, then think about adding it to your website.
Was This Post Helpful? 0
  • +
  • -

#7 dbeaird727  Icon User is offline

  • D.I.C Head

Reputation: -2
  • View blog
  • Posts: 238
  • Joined: 13-December 10

Re: advantages of using php instead of html

Posted 27 August 2011 - 03:55 PM

Let me ask this, beginner question I know, but would I have to "echo" out the template somehow or can the main design of the template be made from html?
Was This Post Helpful? 0
  • +
  • -

#8 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:26 PM

Generally speaking, if I was not following a code separation format, I would normally make my template into a class like the following,

<?php

class template
{
    public function headerT()
    {
      ?>
         All header html code here
       <?php
    }
}

?>



Something like that suits me to what I need

This post has been edited by aaron1178: 27 August 2011 - 05:27 PM

Was This Post Helpful? 0
  • +
  • -

#9 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10440
  • View blog
  • Posts: 38,673
  • Joined: 27-December 08

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:40 PM

I strongly discourage mixing HTML and PHP in an unorganized manner in the same file. As RudiVisser said, they are separate languages. PHP is processed on the server side and is used for dynamic functionality. HTML is displayed on the client-side and is simply a markup language for telling the browser how to display the text. PHP can modify the HTML sent to the browser. This should be controlled and organized though. CTphpnwb's tutorial on code separation is a good starting point.

This post has been edited by macosxnerd101: 27 August 2011 - 05:48 PM
Reason for edit:: Added some clarification

Was This Post Helpful? 2
  • +
  • -

#10 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5227
  • View blog
  • Posts: 27,007
  • Joined: 10-May 07

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:43 PM

View Postmacosxnerd101, on 27 August 2011 - 08:40 PM, said:

I strongly discourage mixing HTML and PHP.

Each language has it's place. Just because they are in fact different langauges does not mean they are not meant to be used together.

How would you suggest using php to prepare html code for a users web browser if not mixed together?
Was This Post Helpful? 0
  • +
  • -

#11 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10440
  • View blog
  • Posts: 38,673
  • Joined: 27-December 08

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:47 PM

Quote

Each language has it's place. Just because they are in fact different langauges does not mean they are not meant to be used together.

I linked to CTphpnwb's tutorial for this. PHP will probably manipulate the HTML at some point, but cramming raw HTML into PHP files can get messy.

This would be messy:
<?php
    ...code..
?>
<html>
<head>
    <title>

    </title>
</head>

<body>
<?php

?>
</body>
</html>



Whereas using PHP to read the HTML files, manipulate the text, and output it at once in a more organized and controlled manner is better practice.
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5227
  • View blog
  • Posts: 27,007
  • Joined: 10-May 07

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:51 PM

View Postmacosxnerd101, on 27 August 2011 - 08:47 PM, said:

PHP will probably manipulate the HTML at some point, but cramming raw HTML into PHP files can get messy.

Of course it will get messy. Man up & roll up your sleeves. ;)

What language doesn't get messy? As long as the developer sticks to a readable syntax that they understand, there is no reason why the languages can't be mixed. A lot of tutorials on the internet show this style, & I've always found it to be perfectly acceptable. Again granted that the author/developer keeps to a proper syntax, indenting, & so on.

They are both web languages, I just don't agree that the author should strive to keep them separated, unless it's what they understand best.

I will read the link that you provided.
Was This Post Helpful? 2
  • +
  • -

#13 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10440
  • View blog
  • Posts: 38,673
  • Joined: 27-December 08

Re: advantages of using php instead of html

Posted 27 August 2011 - 05:56 PM

The other reason to advocate for separating the HTML and PHP is that it makes both more maintainable. I'm not a designer. If I'm asked to do graphics work, it will be crap. I'd rather delegate the design portion to the designers and let them crank out an HTML template with portions that I can modify with PHP. It makes both more maintainable and allows for better component delegation, imo. If you're doing both on your own, that might be one thing. I've seen a couple competent programmers do this, and found their code to be inflexible and difficult to read and maintain. (I guess you could argue competence based on style, but they could problem solve and what not). In contrast, I've found it easier to work with people's code who better separate their PHP and HTML. Just my $0.02. :)
Was This Post Helpful? 2
  • +
  • -

#14 aaron1178  Icon User is offline

  • Dovakiin, Dragonborn
  • member icon

Reputation: 169
  • View blog
  • Posts: 1,298
  • Joined: 22-October 08

Re: advantages of using php instead of html

Posted 27 August 2011 - 06:21 PM

@Mac Code Separation is something newer to web development, I remember coming here asking questions about this when I first signed up and no one suggested code separation. I do have to say, it is easier and more... lets say professional to separate your code, but it is not 'always' necessary. It's only been what, in the last year maybe longer that people have started to separate their code.

Look at this site, its engine 'IP board', they hardly use code separation, except for stuff like 'including css or javascript' ect. My point being, code separation 'is' good practice, but is not always necessary.
Was This Post Helpful? 0
  • +
  • -

#15 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10440
  • View blog
  • Posts: 38,673
  • Joined: 27-December 08

Re: advantages of using php instead of html

Posted 27 August 2011 - 06:23 PM

Arguably, good coding practices aren't 'necessary'; they just make things a lot easier on people maintaining the code. :)
Was This Post Helpful? 2
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2