Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.lang.php > #18702
| From | "J.O. Aho" <user@example.net> |
|---|---|
| Newsgroups | comp.lang.php, alt.comp.lang.php, alt.php |
| Subject | Re: Newbie needs recommendation for fast learning a little php. |
| Date | 2021-07-01 08:03 +0200 |
| Message-ID | <ik545bF93qmU1@mid.individual.net> (permalink) |
| References | (1 earlier) <35nodg56nqinnfigtl6251fhlpkb42vb61@4ax.com> <ik3d56Fti4nU1@mid.individual.net> <ogbpdgl0n036k6ughn109an0kms17jl59s@4ax.com> <ik4264F3479U1@mid.individual.net> <4mcqdgtiqjshpeg88h50b5l97fp3qmflfu@4ax.com> |
Cross-posted to 3 groups.
On 01/07/2021 06.49, Not_even_a_newbie@example.net wrote:
> On Wed, 30 Jun 2021 22:23:32 +0200, "J.O. Aho" <user@example.net>
> wrote:
>
>>
>> On 30/06/2021 19.49, Not_even_a_newbie@example.net wrote:
>>> On Wed, 30 Jun 2021 16:24:38 +0200, "J.O. Aho" <user@example.net>
>>> wrote:
>>>
>>>> On 30/06/2021 14.08, Not_even_a_newbie@example.net wrote:
>>>>> This does what I want, but only as a .PHP file. How do I get it into a
>>>>> file named foo.html so I can have foo.html declare when it was last
>>>>> modified?
>>>>>
>>>>> <?php
>>>>> $file = $_SERVER["SCRIPT_NAME"];
>>>>> $break = Explode('/', $file);
>>>>> $pfile = $break[count($break) - 1];
>>>>> //echo $pfile;
>>>>> echo "This file was last modified on: " .date("Y-m-d
>>>>> H:m",filemtime($pfile));
>>>>> ?>
>>>>>
>>>>> I feel as if I'm almost there.
>>>>
>>>> I won't comment on the code as Arno already done that, there is two
>>>> options, I would say one option is not up to you, so in reality you have
>>>> only one option (the last one)
>>>>
>>>> 1. Make the webserver to send .html files to tne php engine as it does
>>>> with the .php files.
>>>>
>>>> 2. Rename the .html file to .php
>>>
>>> Uh oh. But I'm reading that I can embed php into a html file. Isn't
>>> that possible?
>>
>> The issue is that the web server will not treat each file it handles as
>> a php code, it will only look for files that ends with php, send those
>> to a PHP-engine which parses the file and executes the php code and then
>> hands back the output to the web server which then sends the output to
>> the end user (the visitor to your web page).
>>
>> It's possible to allow .html/.htm files the same way, but then you need
>> the administration rights of the server, as you are using a shared
>> service, it means you don't have administrator privileges and those you
>> can't do the change.
>
> Thanks for clarifying that. I don't control the server, but I've read
> that those who do can allow html files to be scanned for php code.
> Maybe my Web host has in fact done that. Would I be able to find some
> notation about that in the Web host's phpinfo.php file?
>
> Also, some scripts seem to work in html files and some don't.
>
> The following is the entire code for a file I named hello_1.html
>
> <html>
> <head>
> <title>PHP Test</title>
> </head>
> <body>
> <?php echo '<p>Hello World</p>'; ?>
> </body>
> </html>
>
> It produced the result:
>
> "Hello World
>
> '; ?> "
>
> in the browser. It's obviously got a little problem in the output, but
> it did produce a mostly useful output.
No, it's your web browsers html engine that detects a faulty html tag
with another html tag and tries it best to correct the html and shows
you what it thinks should be shown.
Had you written:
<?php echo 1+1; ?>
your output had been:
yes, nothing at all, and that is the proof of that the php code do not
be executed, had the php engine processed the page before sent to you,
you would have had a 2.
> Attempts to get the php script I actually want to use to run in an
> html file have not, so far, produced the thing the php script tries to
> do or else the file doesn't produce any result at all.
As long it's in a file ending with html/htm it will not be executed, so
matter what you write, nothing will happen, you need to change the
ending to php.
>> So this leads to the only thing you can do, rename your files so that
>> they are called .php instead of .html/.htm.
>
> Yeah, that would be a hassle, but if I can't get the php scripts to
> run in html files that may be what I'll have to do. I'd need to see
> how those php files would interact with the many html files they link
> to.
You just need to change the links to the new page name that ends with
.php and that's it.
>> If you don't want to rename files, then you need to look at javascript
>> solution for displaying last modified document time.
>
> I whipped up a javascript to do what I want days ago, but a lot of
> people keep javascript turned off, so it wouldn't work for them. I
> supposed I could figure out how to get some message put in place of
> the file modification date if javascript is turned off.
Itnernet is nowadays quite useless without javascript, so people tend to
not disable it anymore. The benefit with the javascript is that you can
display time the file was modified based on the users timezone.
--
//Aho
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar
Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-06-29 10:30 -0400
Re: Newbie needs recommendation for fast learning a little php. "J.O. Aho" <user@example.net> - 2021-06-29 21:01 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-06-30 05:58 -0400
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-06-30 08:08 -0400
Re: Newbie needs recommendation for fast learning a little php. Arno Welzel <usenet@arnowelzel.de> - 2021-06-30 15:09 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-06-30 13:46 -0400
Re: Newbie needs recommendation for fast learning a little php. Arno Welzel <usenet@arnowelzel.de> - 2021-07-01 10:49 +0200
Re: Newbie needs recommendation for fast learning a little php. "J.O. Aho" <user@example.net> - 2021-06-30 16:24 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-06-30 13:49 -0400
Re: Newbie needs recommendation for fast learning a little php. "J.O. Aho" <user@example.net> - 2021-06-30 22:23 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-01 00:49 -0400
Re: Newbie needs recommendation for fast learning a little php. "J.O. Aho" <user@example.net> - 2021-07-01 08:03 +0200
Re: Newbie needs recommendation for fast learning a little php. Arno Welzel <usenet@arnowelzel.de> - 2021-07-01 12:35 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-02 18:21 -0400
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-02 19:36 -0400
Re: Newbie needs recommendation for fast learning a little php. John-Paul Stewart <jpstewart@personalprojects.net> - 2021-07-02 20:01 -0400
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-03 00:08 -0400
Re: Newbie needs recommendation for fast learning a little php. Arno Welzel <usenet@arnowelzel.de> - 2021-07-03 15:40 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-03 14:36 -0400
Re: Newbie needs recommendation for fast learning a little php. rcpj@panix.com (Pierre Jelenc) - 2021-07-01 21:36 +0000
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-02 18:49 -0400
Re: Newbie needs recommendation for fast learning a little php. rcpj@panix.com (Pierre Jelenc) - 2021-07-02 23:02 +0000
Re: Newbie needs recommendation for fast learning a little php. Arno Welzel <usenet@arnowelzel.de> - 2021-07-01 12:29 +0200
Re: Newbie needs recommendation for fast learning a little php. Ray_Net <Ray_Net@picarre.be.invalid> - 2021-06-30 23:03 +0200
Re: Newbie needs recommendation for fast learning a little php. Not_even_a_newbie@example.net - 2021-07-02 18:07 -0400
Re:Newbie needs recommendation for fast learning a little php. Blue Hat <blue_hat@hackershaven.com.jm> - 2021-08-08 13:43 -0500
csiph-web