Re: Problem getting included source code to work.



In a very general sense, but considering more subtleties. In a system
where these elements stay the same on every page and where php and html
are isolated from each other, this works and is pretty straight
forward.

What I am looking at are pages that load various forms, wich are
largely html but which contain php items lilke option lists drawn from
a lookup table or form fields filled in from a php/mysql generated
array or "while loops" populating an html form.

When all of this html code is included interspersed with php code, the
file gets pretty messy and, since the various kinds of code are
interspersed, it is hard to separate it out the function from the
content. I think there are some sphisticated ways to do this using
placeholders and the like.

In addition, it is convenient to be able to make changes to the html or
associate databases and the html forms that relate to them to in a way
thatdoesn't affect the core php code or even better, have php code that
can adpt to these changes.

It's the old saw about separating form from content. It's possible, of
course to create functions that contain entire sections of the code and
call the functions. but this doesn't separate form and content; it
simply modularizes the script. I'm looking for womething a bit more
elegant.

As an example, heredoc is a useful tool for including large sections of
html interspersed with php elements as it will interpret them just as a
print() statement will. this makes it possible to separate out large
blocks of html and then insert them into php code where needed. I
should even be possible to write code that can parse the data submitted
by the form and adapt itself to what it gets, even modify fields in a
database to conform to new form data.

What I have learned in this exchange is the need to put php tags in my
included files. that solved my immediate problem. I've got lots of
other questions like the value of calling functions from within
template files or in the mother file, how to separate out html into an
included file when using a loop to populate certain html elements, and
how to make code flexible enough to adapt to changes in html input.

Thanks,

--Kenoli

.



Relevant Pages

  • Re: "Best" coding practice?
    ... > The goal is not to seperate HTML and PHP, ... Using a loop inside your HTML is not a bad thing, ... MVC to separate presentation logic and bussines logic. ... and stuffing too much into template in order to handle ...
    (alt.php)
  • Re: "Best" coding practice?
    ... > The goal is not to seperate HTML and PHP, ... Using a loop inside your HTML is not a bad thing, ... MVC to separate presentation logic and bussines logic. ... and stuffing too much into template in order to handle ...
    (comp.lang.php)
  • Re: How do we get there from here?
    ... > then sub the whole of that generated markup into the template? ... layed out on the fly, a simple IMG tag, or even an entire HTML document. ... PHP scripting provides 10 times the features of both of these ... idea as tokens can eliminate a huge amount of maintance, ...
    (comp.databases.pick)
  • Re: query string passing woes........ help... please....
    ... |> | offer any help other than saying that my validation could be FAR more ... I'm a total newbie at php. ... The easiest way for you would be to make the html form called form.php ... $_SESSION array using the same names. ...
    (alt.php)
  • Re: HELP - Cant change Include Path
    ... Here is my php.ini path for the php.ini in both php and sql dirs: ... which did work on the remote linux server and sent me some mail ... Although my gmail acct picked the mail up as ... an attachment instead of as html - but gmail is really wierd about ...
    (comp.lang.php)