FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » when incuding a page
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
when incuding a page [message #184111] Fri, 06 December 2013 17:05 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
<?php inlcude "page.html" ?>

Should the include page be a complete page with headers or not?

The validator throws a hissy fit when doing so.

If not, then how does one properly include the stuff for that page?
Such as CSS or javascript.
Re: when incuding a page [message #184112 is a reply to message #184111] Fri, 06 December 2013 17:16 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 06/12/13 18:05, richard wrote:
> <?php inlcude "page.html" ?>
>
> Should the include page be a complete page with headers or not?

Depends on how you have written things.


> The validator throws a hissy fit when doing so.

Then you didn't write things properly.


> If not, then how does one properly include the stuff for that page?
> Such as CSS or javascript.

As you would for a normal html page.


--

//Aho
Re: when incuding a page [message #184113 is a reply to message #184112] Fri, 06 December 2013 17:29 Go to previous messageGo to next message
Dennis is currently offline  Dennis
Messages: 17
Registered: February 2004
Karma: 0
Junior Member
On 06/12/13 18:05, RtS wrote:
> <?php inlcude "page.html" ?>

And it would help if you spelled "include" correctly.

--

Dennis
Re: when incuding a page [message #184114 is a reply to message #184111] Fri, 06 December 2013 18:09 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
richard the sto0pid wrote:

> <?php inlcude "page.html" ?>

Maybe if you speeled it correctly.

> Should the include page be a complete page with headers or not?

The correct answer is: it depends.

> The validator throws a hissy fit when doing so.

Then you've once again coded with errors.

> If not, then how does one properly include the stuff for that page?
> Such as CSS or javascript.

It depends.

Just think: if you were to pay someone from Bangladesh a couple hundred
dollars, your site would be up and working by Monday. And *look* nice as
well.

--
-bts
-This space for rent, but the price is high
Re: when incuding a page [message #184115 is a reply to message #184111] Fri, 06 December 2013 19:33 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
On 06/12/13 17:05, richard wrote:
> <?php inlcude "page.html" ?>
> ^^^^^^^

Computers prefer people who can spell correctly.
and use the correct syntax...

Your are not the PFY and you are pulling our legs



--
Ineptocracy

(in-ep-toc’-ra-cy) – a system of government where the least capable to
lead are elected by the least capable of producing, and where the
members of society least likely to sustain themselves or succeed, are
rewarded with goods and services paid for by the confiscated wealth of a
diminishing number of producers.
Re: when incuding a page [message #184116 is a reply to message #184111] Fri, 06 December 2013 19:44 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
richard wrote:

> <?php inlcude "page.html" ?>
>
> Should the include page be a complete page with headers or not?
>
> The validator throws a hissy fit when doing so.
>
> If not, then how does one properly include the stuff for that page?
> Such as CSS or javascript.

Well, actually the include statement does not include a _page_, but
rather the contents of a *file*. This basically works the same, as if
the file contents were inserted instead of <?php include 'whatever'?>.

If you have to include a "page" (i.e. an HTML document) stored in a
file, you might be better off to display it as an IFRAME.

--
Christoph M. Becker
Re: when incuding a page [message #184117 is a reply to message #184111] Fri, 06 December 2013 20:15 Go to previous messageGo to next message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma: 0
Member
On Fri, 6 Dec 2013 12:05:46 -0500, richard <noreply(at)example(dot)com>
wrote:

> <?php inlcude "page.html" ?>
>
> Should the include page be a complete page with headers or not?
>
> The validator throws a hissy fit when doing so.
>
> If not, then how does one properly include the stuff for that page?
> Such as CSS or javascript.

include inserts the contents of a file. That can be a whole html page
or a fragment of code.

Think of include as exactly the same as manually copy-and-pasting the
contents of the file.

So, for instance, if your page already has a <head> section before the
include, then you probably do not want to have a <head> section in the
included file. If you are including php code inside a section of php
code, then you do not need <?php....?> in the included file. But if it
is being inserted into the middle of html then you do need those.

Again, just think of it as: include is just copy-and-pasting the
contents of a file.
Re: when incuding a page [message #184118 is a reply to message #184111] Fri, 06 December 2013 21:35 Go to previous messageGo to next message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma: 0
Senior Member
On 12/6/2013 9:05 AM, richard wrote:
> <?php inlcude "page.html" ?>
>
> Should the include page be a complete page with headers or not?
>
> The validator throws a hissy fit when doing so.
>
> If not, then how does one properly include the stuff for that page?
> Such as CSS or javascript.
>

allow me to add that even though the ending semicolon is not needed for
this particular line, YOU may want to put it there to minimize the error
you come back here with when you add another line and forgot to add the
semicolon.

Scotty
Re: when incuding a page [message #184213 is a reply to message #184111] Sun, 15 December 2013 17:42 Go to previous messageGo to next message
Fyndhorn Elder is currently offline  Fyndhorn Elder
Messages: 3
Registered: December 2013
Karma: 0
Junior Member
richard <noreply(at)example(dot)com> writes:

> <?php inlcude "page.html" ?>
>
> Should the include page be a complete page with headers or not?

Look at the source code in your browser (right-click or CTRL-click on a mac mouse), select the view source menuitem. You'll see what is included on the output of your PHP script.

>
> The validator throws a hissy fit when doing so.
>

The correct syntax is include("string") or include('string literal')

> If not, then how does one properly include the stuff for that page?
> Such as CSS or javascript.
>

Again, watch the output in the source view of your browser.

HTH,
FE

--
Time heals.
My blog : https://thediaryofelvishhealer.blogger.com
Re: when incuding a page [message #184215 is a reply to message #184213] Sun, 15 December 2013 18:34 Go to previous messageGo to next message
Christoph Michael Bec is currently offline  Christoph Michael Bec
Messages: 207
Registered: June 2013
Karma: 0
Senior Member
Fyndhorn Elder wrote:

> richard <noreply(at)example(dot)com> writes:
>
>> <?php inlcude "page.html" ?>
>>
>> Should the include page be a complete page with headers or not?
>
> Look at the source code in your browser (right-click or CTRL-click on a mac mouse), select the view source menuitem. You'll see what is included on the output of your PHP script.
>
>>
>> The validator throws a hissy fit when doing so.
>>
>
> The correct syntax is include("string") or include('string literal')

include is not a function, but a statement, so the parentheses are not
required.

--
Christoph M. Becker
Re: when incuding a page [message #184217 is a reply to message #184215] Sun, 15 December 2013 19:34 Go to previous messageGo to next message
Moon Elf is currently offline  Moon Elf
Messages: 6
Registered: December 2013
Karma: 0
Junior Member
On 2013-12-15, Christoph Michael Becker <cmbecker69(at)arcor(dot)de> wrote:
> Fyndhorn Elder wrote:
>
>> richard <noreply(at)example(dot)com> writes:
>>
>>> <?php inlcude "page.html" ?>
>>>
>>> Should the include page be a complete page with headers or not?
>>
>> Look at the source code in your browser (right-click or CTRL-click on a mac
mouse), select the view source menuitem. You'll see what is included on the
output of your PHP script.
>>
>>>
>>> The validator throws a hissy fit when doing so.
>>>
>>
>> The correct syntax is include("string") or include('string literal')
>
> include is not a function, but a statement, so the parentheses are not
> required.
>

Indeed, you can write include "filename" or include 'filename' with a ; at the
end but your parser does not accept closures as in JS e.g. new.

ME
--
Member of the DR rogue circle.
Search and you will find.
Re: when incuding a page [message #184226 is a reply to message #184217] Sun, 15 December 2013 21:10 Go to previous messageGo to next message
Ben Bacarisse is currently offline  Ben Bacarisse
Messages: 82
Registered: November 2013
Karma: 0
Member
Moon Elf <moonelf(at)moonelfsystem(dot)net> writes:

> On 2013-12-15, Christoph Michael Becker <cmbecker69(at)arcor(dot)de> wrote:
>> Fyndhorn Elder wrote:
>>
>>> richard <noreply(at)example(dot)com> writes:
>>>
>>>> <?php inlcude "page.html" ?>

(It's been pointed out before, but there is a typo there: "incl" not
"inlc".)

>>>> Should the include page be a complete page with headers or not?
<snpi>
>>> The correct syntax is include("string") or include('string literal')
>>
>> include is not a function, but a statement, so the parentheses are not
>> required.
>
> Indeed, you can write include "filename" or include 'filename' with a
> ; at the end but your parser does not accept closures as in JS
> e.g. new.

What's the connection with closures?

--
Ben.
Re: when incuding a page [message #184297 is a reply to message #184215] Fri, 20 December 2013 17:57 Go to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Christoph Michael Becker wrote:

> Fyndhorn Elder wrote:
>> richard <noreply(at)example(dot)com> writes:
>>> <?php inlcude "page.html" ?>
>> […]
>> The correct syntax is include("string") or include('string literal')
>
> include is not a function, but a statement, so the parentheses are not
> required.

The fascinating thing about “include” is that it works like a function
although it is a statement. If the include is successful, it returns 1 by
default, otherwise FALSE. And if the include is successful, and the
included PHP script contains a “return” statement, then the value of the
“return” statement's parameter (for lack of a better word) is the return
value of „include“ if execution reaches that statement.

However, in general it is considered good style to omit the parentheses.
It is considered even better style to avoid include* and require* when
possible, in favor of autoloading.

See also:

<http://php.net/include>
<http://pear.php.net/manual/en/standards.including.php>
<http://pear.php.net/manual/en/pear2cs.rules.php>
<http://php.net/autoload>

Unfortunately, so far the difference between function-like statements and
functions has never been made clear using different, but consistent code
style in the PHP manual.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: working model of the latest project
Next Topic: Include gives warning
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Jun 05 21:43:27 GMT 2024

Total time taken to generate the page: 0.02477 seconds