Php include forms or make functions of

forms

#1

Hi

I am building a small application and am learning the best way to make an easily maintainable / encapsulated form.

I am wondering is it best practice to make a “function” of the form or “include” it as a HTML include file.

As I repeat the same form through several scripts.

This is a subjective question, but I am wondering what a good quality website looks like (functionally programmed - my current skill set :frowning:

Any commentary on include files vs functions appreciated!

As really they seem to both produce the same outcome.

Thanks!
Karen


#2

If you are going to use the form multiple times then just include it where needed.


#3

Sure is this faster? Easier? More secure? Easier to manage long term?


#4

Easier. In includes you can just use HTML, which is a lot easier to read than echo’ing out a bunch of HTML from a function.

Functions would probably be faster, but only marginally, and the loss of readability and maintainability is not worth it.

Security has nothing to do with it.


#5

Great thx you two!!

Will do :slight_smile:

Karen