why php echo does not show up in HTML? [message #181613] |
Fri, 24 May 2013 08:08 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
newbie.
could someone explain why this does not work?
<!DOCTYPE html>
<html>
<body>
<p>before
<?php echo "do you see this?"; ?>
<p>after
</body>
</html>
I spend 2 hrs and tried everything and read many things, but message
in echo does not show on the browser. I upload this to the web server.
I also have local web server running. Both support php. I see no error
in the access log file and no error in the php error log file. So the
page is bring loaded OK by the web server. But I do not see the echo.
What Ami doing wrong?
cheers,
steve
|
|
|
Re: why php echo does not show up in HTML? [message #181614 is a reply to message #181613] |
Fri, 24 May 2013 08:50 |
Andy
Messages: 8 Registered: March 2002
Karma: 0
|
Junior Member |
|
|
"steve nospam" <steve(dot)nospamm(at)gmail(dot)com> wrote in message
news:78f2c263-051b-4b12-b2fc-049aeae3fdd6(at)z8g2000yqd(dot)googlegroups(dot)com...
> newbie.
>
> could someone explain why this does not work?
>
> <!DOCTYPE html>
> <html>
> <body>
> <p>before
>
> <?php echo "do you see this?"; ?>
>
> <p>after
> </body>
> </html>
>
> I spend 2 hrs and tried everything and read many things, but message
> in echo does not show on the browser. I upload this to the web server.
> I also have local web server running. Both support php. I see no error
> in the access log file and no error in the php error log file. So the
> page is bring loaded OK by the web server. But I do not see the echo.
> What Ami doing wrong?
>
> cheers,
> steve
>
Hi Steve,
I'm no expert but try these suggestions...
1: Ensure the file is named whatever.php and not whatever.html
2: Put <?php at the very top of page (e.g. <?php // comment ?>)
3: Try <?php $test = "do you see this?";?> <?php echo $test;?>
Hope this helps
Andy
|
|
|
Re: why php echo does not show up in HTML? [message #181615 is a reply to message #181613] |
Fri, 24 May 2013 08:53 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
On May 24, 3:08 am, steve nospam <steve.nosp...@gmail.com> wrote:
> newbie.
>
> could someone explain why this does not work?
>
> <!DOCTYPE html>
> <html>
> <body>
> <p>before
>
> <?php echo "do you see this?"; ?>
>
> <p>after
> </body>
> </html>
>
I have found out by trial and error is that when I change the file
extension to .php instead of .htm, then it works.
However, I read that php can be used inside .htm? I do not want to
change all my .htm file extensions to .php as that will break many
links I have.
|
|
|
Re: why php echo does not show up in HTML? [message #181616 is a reply to message #181615] |
Fri, 24 May 2013 08:57 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
>
> I have found out by trial and error is that when I change the file
> extension to .php instead of .htm, then it works.
>
> However, I read that php can be used inside .htm? I do not want to
> change all my .htm file extensions to .php as that will break many
> links I have.
Another thing I found by trial and error. If I keep the file as .htm,
but change the code to the following, where a <P> was added to inside
the string. That is the only change made.
............................
<!DOCTYPE html>
<html>
<body>
<p>before
<?php echo '<p>do you see this?'; ?>
<p>after
</body>
</html>
....................
Then I get the echo ! But it looks not correct:
before do you see this?'; ?>
So I have no idea what is going on.
|
|
|
Re: why php echo does not show up in HTML? [message #181617 is a reply to message #181613] |
Fri, 24 May 2013 09:06 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
On May 24, 3:08 am, steve nospam <steve.nosp...@gmail.com> wrote:
> newbie.
>
> could someone explain why this does not work?
>
> <!DOCTYPE html>
> <html>
> <body>
> <p>before
>
> <?php echo "do you see this?"; ?>
>
> <p>after
> </body>
> </html>
>
> I spend 2 hrs and tried everything and read many things, but message
> in echo does not show on the browser. I upload this to the web server.
> I also have local web server running. Both support php. I see no error
> in the access log file and no error in the php error log file. So the
> page is bring loaded OK by the web server. But I do not see the echo.
> What Ami doing wrong?
>
> cheers,
> steve
I found the problem.
I needed to modify the .htaccess file. added this line
AddType application/x-httpd-php .htm
Now it works. php works from inside htm file. No need to change file
extension.
|
|
|
Re: why php echo does not show up in HTML? [message #181627 is a reply to message #181617] |
Fri, 24 May 2013 13:20 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
>
> I found the problem.
>
> I needed to modify the .htaccess file. added this line
>
> AddType application/x-httpd-php .htm
>
> Now it works. php works from inside htm file. No need to change file
> extension.
guys, the above fix did not work on the server. Must be something with
the php used there. It worked on my local apache server. So, I still
looking for a solution. My question is this:
If I change my index.htm to index.php, is there a way to make an alias
or something so that not all my links are broken? so that a link to
index.htm will use index.php?
Ok, let me go back one step: This is all crazy, because all what I
wanted to do is simple: use php to include some common html code into
all my html web pages. So how is one supposed to do this if one can't
use php inside html?
I want to use php call to include common HTML code into an html page,
but can't use php from HTML? what is the deal here? So, how do people
do this thing then?
|
|
|
Re: why php echo does not show up in HTML? [message #181630 is a reply to message #181614] |
Fri, 24 May 2013 13:25 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 4:50 AM, Andy wrote:
>
>
> "steve nospam" <steve(dot)nospamm(at)gmail(dot)com> wrote in message
> news:78f2c263-051b-4b12-b2fc-049aeae3fdd6(at)z8g2000yqd(dot)googlegroups(dot)com...
>> newbie.
>>
>> could someone explain why this does not work?
>>
>> <!DOCTYPE html>
>> <html>
>> <body>
>> <p>before
>>
>> <?php echo "do you see this?"; ?>
>>
>> <p>after
>> </body>
>> </html>
>>
>> I spend 2 hrs and tried everything and read many things, but message
>> in echo does not show on the browser. I upload this to the web server.
>> I also have local web server running. Both support php. I see no error
>> in the access log file and no error in the php error log file. So the
>> page is bring loaded OK by the web server. But I do not see the echo.
>> What Ami doing wrong?
>>
>> cheers,
>> steve
>>
>
> Hi Steve,
>
> I'm no expert but try these suggestions...
>
> 1: Ensure the file is named whatever.php and not whatever.html
>
Most probably the problem.
> 2: Put <?php at the very top of page (e.g. <?php // comment ?>)
>
Completely unnecessary. The <?php can appear anywhere in the page.
> 3: Try <?php $test = "do you see this?";?> <?php echo $test;?>
>
Which does nothing (except complicate the matter).
>
> Hope this helps
>
> Andy
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181631 is a reply to message #181613] |
Fri, 24 May 2013 13:35 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 4:08 AM, steve nospam wrote:
> newbie.
>
> could someone explain why this does not work?
>
> <!DOCTYPE html>
> <html>
> <body>
> <p>before
>
> <?php echo "do you see this?"; ?>
>
> <p>after
> </body>
> </html>
>
> I spend 2 hrs and tried everything and read many things, but message
> in echo does not show on the browser. I upload this to the web server.
> I also have local web server running. Both support php. I see no error
> in the access log file and no error in the php error log file. So the
> page is bring loaded OK by the web server. But I do not see the echo.
> What Ami doing wrong?
>
> cheers,
> steve
>
Look at the source in your browser. You will see the message, including
the <?php echo...
The web server will not (by default) pass pages to the PHP interpreter
unless they have a .php extension. You can include PHP code in html
code, but need to parse them as PHP.
If you're using Apache, you could change the Apache configuration to
pass all pages to the PHP interpreter, but this can cause extra load on
the server due to unnecessarily parsing non-PHP pages as PHP code. It
is also not portable and will not run on hosts where this type of
configuration is not allowed.
Your best bet is to simply change the files you need to include PHP code
in to a .php extension and fix the links on your site. For external
links, configure your web server to do a permanent redirect from the old
page to the new (see your web server configuration for more information
on how to do this).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181632 is a reply to message #181627] |
Fri, 24 May 2013 13:40 |
Tim Streater
Messages: 328 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
In article
<cffe44b6-a68e-49ab-8c19-d0fd55e7f3d1(at)d6g2000yqi(dot)googlegroups(dot)com>,
steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote:
>>
>> I found the problem.
>>
>> I needed to modify the .htaccess file. added this line
>>
>> AddType application/x-httpd-php .htm
>>
>> Now it works. php works from inside htm file. No need to change file
>> extension.
>
> guys, the above fix did not work on the server. Must be something with
> the php used there. It worked on my local apache server. So, I still
> looking for a solution. My question is this:
>
> If I change my index.htm to index.php, is there a way to make an alias
> or something so that not all my links are broken? so that a link to
> index.htm will use index.php?
>
> Ok, let me go back one step: This is all crazy, because all what I
> wanted to do is simple: use php to include some common html code into
> all my html web pages. So how is one supposed to do this if one can't
> use php inside html?
>
> I want to use php call to include common HTML code into an html page,
> but can't use php from HTML? what is the deal here? So, how do people
> do this thing then?
You get your:
AddType application/x-httpd-php .htm
added to the apache config file on the server.
However, you should note if if you do that, any .htm file will be sent
to PHP by apache, even if there is no PHP in it. That adds an extra step
to getting your files served up. That is why people have been suggesting
to change the files which use PHP to have a .php extension.
Personally I add:
AddType application/x-httpd-php .phtml
to the apache config file, and use that for files containing any PHP.
That way the PHP interpreter is only involved when a file actually has
PHP in it.
--
Tim
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
|
|
|
Re: why php echo does not show up in HTML? [message #181633 is a reply to message #181632] |
Fri, 24 May 2013 13:55 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 9:40 AM, Tim Streater wrote:
> In article
> <cffe44b6-a68e-49ab-8c19-d0fd55e7f3d1(at)d6g2000yqi(dot)googlegroups(dot)com>,
> steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote:
>
>>>
>>> I found the problem.
>>>
>>> I needed to modify the .htaccess file. added this line
>>>
>>> AddType application/x-httpd-php .htm
>>>
>>> Now it works. php works from inside htm file. No need to change file
>>> extension.
>>
>> guys, the above fix did not work on the server. Must be something with
>> the php used there. It worked on my local apache server. So, I still
>> looking for a solution. My question is this:
>>
>> If I change my index.htm to index.php, is there a way to make an alias
>> or something so that not all my links are broken? so that a link to
>> index.htm will use index.php?
>>
>> Ok, let me go back one step: This is all crazy, because all what I
>> wanted to do is simple: use php to include some common html code into
>> all my html web pages. So how is one supposed to do this if one can't
>> use php inside html?
>>
>> I want to use php call to include common HTML code into an html page,
>> but can't use php from HTML? what is the deal here? So, how do people
>> do this thing then?
>
> You get your:
>
> AddType application/x-httpd-php .htm
>
> added to the apache config file on the server.
>
> However, you should note if if you do that, any .htm file will be sent
> to PHP by apache, even if there is no PHP in it. That adds an extra step
> to getting your files served up. That is why people have been suggesting
> to change the files which use PHP to have a .php extension.
>
> Personally I add:
>
> AddType application/x-httpd-php .phtml
>
> to the apache config file, and use that for files containing any PHP.
> That way the PHP interpreter is only involved when a file actually has
> PHP in it.
>
What's the difference between using .phtml and .php (other than the
former is non-standard and will not work on all systems)?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181635 is a reply to message #181627] |
Fri, 24 May 2013 14:00 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 24/05/13 14:20, steve nospam wrote:
>> I found the problem.
>>
>> I needed to modify the .htaccess file. added this line
>>
>> AddType application/x-httpd-php .htm
>>
>> Now it works. php works from inside htm file. No need to change file
>> extension.
> guys, the above fix did not work on the server. Must be something with
> the php used there. It worked on my local apache server. So, I still
> looking for a solution. My question is this:
>
> If I change my index.htm to index.php, is there a way to make an alias
> or something so that not all my links are broken? so that a link to
> index.htm will use index.php?
>
> Ok, let me go back one step: This is all crazy, because all what I
> wanted to do is simple: use php to include some common html code into
> all my html web pages. So how is one supposed to do this if one can't
> use php inside html?
|echo (file_get_contents( "filename.htm" ));|
?
>
> I want to use php call to include common HTML code into an html page,
> but can't use php from HTML? what is the deal here? So, how do people
> do this thing then?
>
>
--
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: why php echo does not show up in HTML? [message #181636 is a reply to message #181631] |
Fri, 24 May 2013 14:14 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
> Your best bet is to simply change the files you need to include PHP code
> in to a .php extension and fix the links on your site. For external
> links, configure your web server to do a permanent redirect from the old
> page to the new (see your web server configuration for more information
> on how to do this).
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
I can't do this. I need to include common html code to every html file
I have. This means I have to change the extension of 1000's of html
files to .php and therefore any outside links and any google searches
will be broken now.
May be I should have done this at first, but too late now to change
index.htm to index.php.
|
|
|
Re: why php echo does not show up in HTML? [message #181637 is a reply to message #181632] |
Fri, 24 May 2013 14:19 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
>
> You get your:
>
> AddType application/x-httpd-php .htm
>
> added to the apache config file on the server.
>
What I did is add the above line to my .htaccess file on my home page.
And it worked for apache server on my PC. But when I did the same for
my hosting company, then what happens when I clicked on the file, the
browser was asking me to download the .htm file ! instead of opening
it
as a web page.
Do you think I need to add the above line to apache config file? But
my hosting company is public company, I have no control over what web
server they are using and I can't ask them to edit the web server
config files for me. This is a shared server.
> However, you should note if if you do that, any .htm file will be sent
> to PHP by apache, even if there is no PHP in it. That adds an extra step
> to getting your files served up. That is why people have been suggesting
> to change the files which use PHP to have a .php extension.
>
It is not the delay isssue. It simply did not work as I said above.
> Personally I add:
>
> AddType application/x-httpd-php .phtml
>
> to the apache config file, and use that for files containing any PHP.
> That way the PHP interpreter is only involved when a file actually has
> PHP in it.
>
I can't edit the web server config files on the my hosting ISP
computer !
|
|
|
|
Re: why php echo does not show up in HTML? [message #181640 is a reply to message #181635] |
Fri, 24 May 2013 14:34 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 10:00 AM, The Natural Philosopher wrote:
> On 24/05/13 14:20, steve nospam wrote:
>>> I found the problem.
>>>
>>> I needed to modify the .htaccess file. added this line
>>>
>>> AddType application/x-httpd-php .htm
>>>
>>> Now it works. php works from inside htm file. No need to change file
>>> extension.
>> guys, the above fix did not work on the server. Must be something with
>> the php used there. It worked on my local apache server. So, I still
>> looking for a solution. My question is this:
>>
>> If I change my index.htm to index.php, is there a way to make an alias
>> or something so that not all my links are broken? so that a link to
>> index.htm will use index.php?
>>
>> Ok, let me go back one step: This is all crazy, because all what I
>> wanted to do is simple: use php to include some common html code into
>> all my html web pages. So how is one supposed to do this if one can't
>> use php inside html?
>
> |echo (file_get_contents( "filename.htm" ));|
>
> ?
ROFLMAO! Typical of your level of comprehension, TNP.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181641 is a reply to message #181638] |
Fri, 24 May 2013 14:35 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 10:20 AM, steve nospam wrote:
> On May 24, 9:00 am, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>
>>
>> |echo (file_get_contents( "filename.htm" ));|
>>
>> ?
>>
>
> huh? what is this?
>
The usual tripe TNP espouses. He's not very smart and his comprehension
is lacking.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181642 is a reply to message #181636] |
Fri, 24 May 2013 14:38 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 10:14 AM, steve nospam wrote:
>
>> Your best bet is to simply change the files you need to include PHP code
>> in to a .php extension and fix the links on your site. For external
>> links, configure your web server to do a permanent redirect from the old
>> page to the new (see your web server configuration for more information
>> on how to do this).
>>
>
> I can't do this. I need to include common html code to every html file
> I have. This means I have to change the extension of 1000's of html
> files to .php and therefore any outside links and any google searches
> will be broken now.
>
You only need to change the file names for those files which include php
code. Files which do not contain HTML code need no changes. But yes,
if you're going to add php code to thousands of html files, then you
need to change the extensions of thousands of files.
And no, the external links are NOT broken if you do a permanent redirect
as I suggested before. That's what it is there for.
> May be I should have done this at first, but too late now to change
> index.htm to index.php.
>
No, it is not too late if you understand how to properly configure your
web server.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181643 is a reply to message #181642] |
Fri, 24 May 2013 14:53 |
steve nospam
Messages: 11 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
On May 24, 9:38 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
> No, it is not too late if you understand how to properly configure your
> web server.
>
I can;t configure or change the web server. As I said, I use a web
hosting
company. I am on a shared sever used by 100's others on the main
server.
I can't call my hosting company talk to tech support and tell to
please
edit the server config files for me and see if this will work.
|
|
|
Re: why php echo does not show up in HTML? [message #181645 is a reply to message #181643] |
Fri, 24 May 2013 15:06 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 10:53 AM, steve nospam wrote:
> On May 24, 9:38 am, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>
>>
>> No, it is not too late if you understand how to properly configure your
>> web server.
>>
>
> I can;t configure or change the web server. As I said, I use a web
> hosting
> company. I am on a shared sever used by 100's others on the main
> server.
>
You can still do redirects. That is something EVERY web host supports.
> I can't call my hosting company talk to tech support and tell to
> please
> edit the server config files for me and see if this will work.
>
If you're using Apache, it can be done in the .htaccess file. Other web
servers have similar ways.
Learn to use the tools you have before claiming something "cannot be done".
Do you want to fix your problem or just cry about it? So far, all
you've done is the latter.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181646 is a reply to message #181637] |
Fri, 24 May 2013 15:02 |
Doug Miller
Messages: 171 Registered: August 2011
Karma: 0
|
Senior Member |
|
|
steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote in news:d52747cd-b74d-4242-8ffe-
ef95fe376a68(at)g3g2000yqg(dot)googlegroups(dot)com:
>
>>
>> You get your:
>>
>> AddType application/x-httpd-php .htm
>>
>> added to the apache config file on the server.
>>
>
> What I did is add the above line to my .htaccess file on my home page.
Wrong place. As Tim told you, you need to add this to the Apache config file.
> And it worked for apache server on my PC.
I doubt that. If you added it to the .htaccess file on your PC, it didn't work. If it did work, you
added to the Apache config file, not the .htaccess file.
> But when I did the same for
> my hosting company, then what happens when I clicked on the file, the
> browser was asking me to download the .htm file ! instead of opening
> it as a web page.
Right, that's what happens when you don't have things configured correctly...
>
> Do you think I need to add the above line to apache config file?
That's where Tim told you to add it....
> But
> my hosting company is public company, I have no control over what web
> server they are using and I can't ask them to edit the web server
> config files for me. This is a shared server.
The way this is normally done is that you create your own Apache config file in your web root
directory, and put whatever you need there that is specific to your configuration. Check with
your hosting provider for details on how to do this on their server.
|
|
|
Re: why php echo does not show up in HTML? [message #181647 is a reply to message #181636] |
Fri, 24 May 2013 15:12 |
Doug Miller
Messages: 171 Registered: August 2011
Karma: 0
|
Senior Member |
|
|
steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote in news:f8f531ee-6d30-49e5-a981-
b7725a253276(at)o2g2000yqb(dot)googlegroups(dot)com:
>
>> Your best bet is to simply change the files you need to include PHP code
>> in to a .php extension and fix the links on your site. For external
>> links, configure your web server to do a permanent redirect from the old
>> page to the new (see your web server configuration for more information
>> on how to do this).
>
> I can't do this.
Yes, you can.
> I need to include common html code to every html file
> I have.
I understand that.
> This means I have to change the extension of 1000's of html
> files to .php and therefore any outside links and any google searches
> will be broken now.
No, it does *not* mean that. As Jerry said -- configure your web server to do a permanent
redirection from the old page to the new.
See http://www.somacon.com/p145.php for ideas. The section most likely to be useful to
you is about 1/3 of the way down the page, "Redirection with mod_rewrite".
> May be I should have done this at first, but too late now to change
> index.htm to index.php.
So don't change them. Redirect them.
|
|
|
Re: why php echo does not show up in HTML? [message #181649 is a reply to message #181643] |
Fri, 24 May 2013 15:18 |
Doug Miller
Messages: 171 Registered: August 2011
Karma: 0
|
Senior Member |
|
|
steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote in
news:ad1267f0-4f45-4044-afc5-699315dd59e6(at)g3g2000yqg(dot)googlegroups(dot)c
om:
> On May 24, 9:38am, Jerry Stuckle <jstuck...@attglobal.net>
> wrote:
>
>>
>> No, it is not too late if you understand how to properly
>> configure your web server.
>>
>
> I can;t configure or change the web server. As I said, I use a
> web hosting company. I am on a shared sever used by 100's
> others on the main server.
That doesn't mean you can't change the configuration for your portion of it.
> I can't call my hosting company talk to tech support and tell to
> please edit the server config files for me and see if this will work.
No, that's true, you can't. Fortunately, you don't need to. You should be able to do everything
you need in the .htaccess file in your web root directory. You possibly will need to add a
php.ini file as well -- see below:
<contents of php.ini>
auto_prepend_file = "<file to be prepended to everything generated by php>"
include_path = "<path(s) to various directories where include files are located>"
expose_php = off
display_errors = off
|
|
|
Re: why php echo does not show up in HTML? [message #181651 is a reply to message #181633] |
Fri, 24 May 2013 15:47 |
Tim Streater
Messages: 328 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
In article <knnr88$4bg$1(at)dont-email(dot)me>,
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
> On 5/24/2013 9:40 AM, Tim Streater wrote:
>> Personally I add:
>>
>> AddType application/x-httpd-php .phtml
>>
>> to the apache config file, and use that for files containing any PHP.
>> That way the PHP interpreter is only involved when a file actually has
>> PHP in it.
>>
>
> What's the difference between using .phtml and .php (other than the
> former is non-standard and will not work on all systems)?
None, I don't suppose, but it was the standard where I used to work. I
just followed it. I use .php for scripts that *only* contain php.
It's a shame that the universe doesn't use proper file metadata but as
we seem to be stuck using extensions they may as well mean something.
--
Tim
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
|
|
|
Re: why php echo does not show up in HTML? [message #181652 is a reply to message #181627] |
Fri, 24 May 2013 15:51 |
Peter H. Coffin
Messages: 245 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Fri, 24 May 2013 06:20:03 -0700 (PDT), steve nospam wrote:
>
>>
>> I found the problem.
>>
>> I needed to modify the .htaccess file. added this line
>>
>> AddType application/x-httpd-php .htm
>>
>> Now it works. php works from inside htm file. No need to change file
>> extension.
>
> guys, the above fix did not work on the server. Must be something with
> the php used there. It worked on my local apache server.
The server configuration may be forbidding FileInfo overrides from
..htaccess. In newer Apache versions, allowing this by default is no
longer the case, either.
> So, I still
> looking for a solution. My question is this:
>
> If I change my index.htm to index.php, is there a way to make an alias
> or something so that not all my links are broken? so that a link to
> index.htm will use index.php?
No. What handler the Apache server uses for type depends on the name.
You cannot use a different thing in the name than what the server is
looking for and get it to work.
--
"It's 106 light-years to Chicago, we've got a full chamber of anti-
matter, a half a pack of cigarettes, it's dark, and we're wearing
visors."
"Engage."
|
|
|
Re: why php echo does not show up in HTML? [message #181653 is a reply to message #181638] |
Fri, 24 May 2013 15:59 |
The Natural Philosoph
Messages: 993 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 24/05/13 15:20, steve nospam wrote:
> On May 24, 9:00 am, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>
>> |echo (file_get_contents( "filename.htm" ));|
>>
>> ?
>>
> huh? what is this?
Its an Answer
--
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: why php echo does not show up in HTML? [message #181655 is a reply to message #181649] |
Fri, 24 May 2013 16:04 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 11:18 AM, Doug Miller wrote:
> steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote in
> news:ad1267f0-4f45-4044-afc5-699315dd59e6(at)g3g2000yqg(dot)googlegroups(dot)c
> om:
>
>> On May 24, 9:38 am, Jerry Stuckle <jstuck...@attglobal.net>
>> wrote:
>>
>>>
>>> No, it is not too late if you understand how to properly
>>> configure your web server.
>>>
>>
>> I can;t configure or change the web server. As I said, I use a
>> web hosting company. I am on a shared sever used by 100's
>> others on the main server.
>
> That doesn't mean you can't change the configuration for your portion of it.
>
>> I can't call my hosting company talk to tech support and tell to
>> please edit the server config files for me and see if this will work.
>
> No, that's true, you can't. Fortunately, you don't need to. You should be able to do everything
> you need in the .htaccess file in your web root directory. You possibly will need to add a
> php.ini file as well -- see below:
>
> <contents of php.ini>
> auto_prepend_file = "<file to be prepended to everything generated by php>"
> include_path = "<path(s) to various directories where include files are located>"
> expose_php = off
> display_errors = off
>
>
>
>
None of which have anything to do with his problem...
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181656 is a reply to message #181651] |
Fri, 24 May 2013 16:07 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 11:47 AM, Tim Streater wrote:
> In article <knnr88$4bg$1(at)dont-email(dot)me>,
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 5/24/2013 9:40 AM, Tim Streater wrote:
>
>>> Personally I add:
>>>
>>> AddType application/x-httpd-php .phtml
>>>
>>> to the apache config file, and use that for files containing any PHP.
>>> That way the PHP interpreter is only involved when a file actually has
>>> PHP in it.
>>>
>>
>> What's the difference between using .phtml and .php (other than the
>> former is non-standard and will not work on all systems)?
>
> None, I don't suppose, but it was the standard where I used to work. I
> just followed it. I use .php for scripts that *only* contain php.
>
That's reasonable, as long as you only run on servers you control. Of
course, someone else's server could cause a problem.
> It's a shame that the universe doesn't use proper file metadata but as
> we seem to be stuck using extensions they may as well mean something.
>
I won't argue that. However, remember when the web started, many os's
didn't support metadata (and some still don't do it properly). And,
unfortunately, once a standard is implemented, it becomes very difficult
to make a non-compatible change (which this would be).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181657 is a reply to message #181656] |
Fri, 24 May 2013 17:04 |
Tim Streater
Messages: 328 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
In article <kno313$kpa$1(at)dont-email(dot)me>,
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
> On 5/24/2013 11:47 AM, Tim Streater wrote:
>> In article <knnr88$4bg$1(at)dont-email(dot)me>,
>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>>
>>> On 5/24/2013 9:40 AM, Tim Streater wrote:
>>
>>>> Personally I add:
>>>>
>>>> AddType application/x-httpd-php .phtml
>>>>
>>>> to the apache config file, and use that for files containing any PHP.
>>>> That way the PHP interpreter is only involved when a file actually has
>>>> PHP in it.
>>> What's the difference between using .phtml and .php (other than the
>>> former is non-standard and will not work on all systems)?
>>
>> None, I don't suppose, but it was the standard where I used to work. I
>> just followed it. I use .php for scripts that *only* contain php.
> That's reasonable, as long as you only run on servers you control. Of
> course, someone else's server could cause a problem.
Yes, in-house servers.
>> It's a shame that the universe doesn't use proper file metadata but as
>> we seem to be stuck using extensions they may as well mean something.
> I won't argue that. However, remember when the web started, many os's
> didn't support metadata (and some still don't do it properly). And,
> unfortunately, once a standard is implemented, it becomes very difficult
> to make a non-compatible change (which this would be).
Agreed, I was just having a whinge. :-) (fed up with it being cold -
it's about 6C today - and we just had a 90 min power outage)
--
Tim
"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
|
|
|
Re: why php echo does not show up in HTML? [message #181658 is a reply to message #181657] |
Fri, 24 May 2013 17:30 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 1:04 PM, Tim Streater wrote:
> In article <kno313$kpa$1(at)dont-email(dot)me>,
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>
>> On 5/24/2013 11:47 AM, Tim Streater wrote:
>>> In article <knnr88$4bg$1(at)dont-email(dot)me>,
>>> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>>>
>>>> On 5/24/2013 9:40 AM, Tim Streater wrote:
>>>
>>>> > Personally I add:
>>>> >
>>>> > AddType application/x-httpd-php .phtml
>>>> >
>>>> > to the apache config file, and use that for files containing any
>> PHP.
>>>> > That way the PHP interpreter is only involved when a file
>> actually has
>>>> > PHP in it.
>
>>>> What's the difference between using .phtml and .php (other than the
>>>> former is non-standard and will not work on all systems)?
>>>
>>> None, I don't suppose, but it was the standard where I used to work. I
>>> just followed it. I use .php for scripts that *only* contain php.
>
>> That's reasonable, as long as you only run on servers you control. Of
>> course, someone else's server could cause a problem.
>
> Yes, in-house servers.
>
I should also add - I do something kinda similar, but not. Files which
only contain PHP code are going to be included in other files. So I'll
have .php as the main extension, and those which will be included as
..inc.php (for included php).
Then there is a subset of that - class files, which I define as .class.php.
You'll never see any of those in a URL, though, since they are all kept
outside the website's document root.
I find it works for me, and is compatible with most hosting companies
(those who do not allow storing files outside of the document root
aren't work using, IMHO).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181660 is a reply to message #181617] |
Fri, 24 May 2013 18:26 |
J.O. Aho
Messages: 194 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 24/05/13 11:06, steve nospam wrote:
> I found the problem.
>
> I needed to modify the .htaccess file. added this line
>
> AddType application/x-httpd-php .htm
>
> Now it works. php works from inside htm file. No need to change file
> extension.
No, you didn't solve anything at all, you just managed to break your
site to not work properly.
When you add that line, all the pages ending with ".htm" will be sent
trough the PHP parser and the majority of your pages will not include
PHP which means you do something unnecessary by sending them to the PHP
engine which has to read the whole file and do nothing more.
The fix is rename the files to .php and remove the line from your
htaccess file. If pages which before been called whatever.htm will
suddenly be whatever.php, then use Rewrite rules to redirect the user to
the new page.
RewriteEngine On
RewriteRule ^whatever.htm$ whatever.php
Now your site will work at the majority of web hosting companies as you
have your PHP in .php files and RewriteRule is in most cases allowed.
Note: When people say you can use PHP in HTML, they ain't talking about
the file extension, but that you can mix plain HTML with PHP code, for
example:
--- example.php ---
<html>
<head>
<title>example file with mixed php and html</title>
</head>
<body>
<h1><?php echo "this is an example"; ?></h1>
<?php echo "this code is quite stupid, but shows how you can make a
badly coded site"; ?>
</body>
</html>
--- eof ---
--
//Aho
|
|
|
Re: why php echo does not show up in HTML? [message #181663 is a reply to message #181660] |
Fri, 24 May 2013 19:34 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 2:26 PM, J.O. Aho wrote:
> On 24/05/13 11:06, steve nospam wrote:
>
>> I found the problem.
>>
>> I needed to modify the .htaccess file. added this line
>>
>> AddType application/x-httpd-php .htm
>>
>> Now it works. php works from inside htm file. No need to change file
>> extension.
>
> No, you didn't solve anything at all, you just managed to break your
> site to not work properly.
>
> When you add that line, all the pages ending with ".htm" will be sent
> trough the PHP parser and the majority of your pages will not include
> PHP which means you do something unnecessary by sending them to the PHP
> engine which has to read the whole file and do nothing more.
>
> The fix is rename the files to .php and remove the line from your
> htaccess file. If pages which before been called whatever.htm will
> suddenly be whatever.php, then use Rewrite rules to redirect the user to
> the new page.
>
> RewriteEngine On
> RewriteRule ^whatever.htm$ whatever.php
>
> Now your site will work at the majority of web hosting companies as you
> have your PHP in .php files and RewriteRule is in most cases allowed.
>
>
> Note: When people say you can use PHP in HTML, they ain't talking about
> the file extension, but that you can mix plain HTML with PHP code, for
> example:
>
> --- example.php ---
> <html>
> <head>
> <title>example file with mixed php and html</title>
> </head>
> <body>
> <h1><?php echo "this is an example"; ?></h1>
> <?php echo "this code is quite stupid, but shows how you can make a
> badly coded site"; ?>
> </body>
> </html>
> --- eof ---
>
This also only bypasses the problem - and will require a redirect for
the life of the website (even if he changes hosts).
Better is to put in a 301 redirect for the pages; search engines will
pick up the redirect and link to the new page.
It can be done easily in the .htaccess file (more info on how to do it
correctly an alt.apache.configuration).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181664 is a reply to message #181651] |
Fri, 24 May 2013 20:32 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma: 0
|
Senior Member |
|
|
Tim Streater wrote:
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>> On 5/24/2013 9:40 AM, Tim Streater wrote:
>>> Personally I add:
>>>
>>> AddType application/x-httpd-php .phtml
>>>
>>> to the apache config file, and use that for files containing any PHP.
>>> That way the PHP interpreter is only involved when a file actually has
>>> PHP in it.
>>>
>>
>> What's the difference between using .phtml and .php (other than the
>> former is non-standard and will not work on all systems)?
>
> None, I don't suppose, but it was the standard where I used to work. I
> just followed it. I use .php for scripts that *only* contain php.
“.phtml” for *templates* is a quasi-standard *at least* since Zend Framework
uses it. IIRC, Eclipse PDT and Zend Studio assign files with “.phtml”
suffix the PHP Editor plugin as default. Using “.phtml” for anything other
than templates is unwise. The convention probably stems from “.shtml” for
SSI.
> It's a shame that the universe doesn't use proper file metadata but as
> we seem to be stuck using extensions they may as well mean something.
ACK.
PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
|
|
|
Re: why php echo does not show up in HTML? [message #181668 is a reply to message #181616] |
Fri, 24 May 2013 22:25 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Fri, 24 May 2013 01:57:54 -0700, steve nospam wrote:
>> I have found out by trial and error is that when I change the file
>> extension to .php instead of .htm, then it works.
>>
>> However, I read that php can be used inside .htm? I do not want to
>> change all my .htm file extensions to .php as that will break many
>> links I have.
This is a matter for the webserver configuration. If you want the
webserver to parse your .htm files with the php preprocessor, then you
have to tell the webserver to do so. Normally the webserver by default
will only send .php files to the php preprocessor.
> Another thing I found by trial and error. If I keep the file as .htm,
> but change the code to the following, where a <P> was added to inside
> the string. That is the only change made.
> <?php echo '<p>do you see this?'; ?>
> Then I get the echo ! But it looks not correct:
>
> before do you see this?'; ?>
>
> So I have no idea what is going on.
Right. What happens here is that the web browser sees:
"<?php echo '<p>"
As an element tag, startiong at "<" and ending at ">" but it does not
recognise it, so it ignores it. Then it sees:
"do you see this?'; ?>"
as document body text, and it displays it in the document body.
By adding the "<p>" you inserted a ">" character after the "<" of "<?php"
and that ">" became the closing marker of the tag.
I've tried to explain this as clearly as I can, please re-read it until
you are sure you understand it.
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|
Re: why php echo does not show up in HTML? [message #181672 is a reply to message #181646] |
Fri, 24 May 2013 22:37 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Fri, 24 May 2013 15:02:47 +0000, Doug Miller wrote:
> steve nospam <steve(dot)nospamm(at)gmail(dot)com> wrote in
> news:d52747cd-b74d-4242-8ffe- ef95fe376a68(at)g3g2000yqg(dot)googlegroups(dot)com:
>>> AddType application/x-httpd-php .htm
>> What I did is add the above line to my .htaccess file on my home page.
> Wrong place. As Tim told you, you need to add this to the Apache config
> file.
>> And it worked for apache server on my PC.
It may depend on the security settings in the config file. See the docs:
http://httpd.apache.org/docs/2.2/mod/mod_mime.html#addtype
Context: server config, virtual host, directory, .htaccess
and:
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
"When this directive is set to All, then any directive which has
the .htaccess Context is allowed in .htaccess files."
If he has "allowoverride all" (or anything else that allows an addtype in
an .htaccess) specified in a the relevant <directory> section of the
apache conf, then inserting addtype in the .htaccess will work as he
describes.
If he wants it to work on the server, he has to convince the server admins
to:
allowoverride fileinfo
for his directory(ies), but the server admins will most likely be very
reluctant to do that because what he intends to do is going to increase
cpu load on the server by sending all his html files through the php
preprocessor.
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|
Re: why php echo does not show up in HTML? [message #181675 is a reply to message #181643] |
Fri, 24 May 2013 22:49 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Fri, 24 May 2013 07:53:52 -0700, steve nospam wrote:
> I can;t configure or change the web server. As I said, I use a web
> hosting company. I am on a shared sever used by 100's others on the main
> server.
>
> I can't call my hosting company talk to tech support and tell to please
> edit the server config files for me and see if this will work.
OK, so here's a list of other things you can not do:
- You can not change the server so that it processes htm files as php
files.
Here's a list of things you can do:
+ You can download all the files from the server webroot to your local
machine to bulk edit them
+ You can use tools such as sed to change every local url from .htm
to .php
+ You can rename all the .htm files to .php files
+ You can automate the redirection of requests to *.htm to serve up the
*.php files instead
+ You can upload all the fixed files to the server webroot
External and existing search engine links will still work, because
requesting the old .htm file will get the new .php file automatically.
This is not a technically difficult fix, although you may need to spend a
bit of time on getting to grips with the changes that need to be made and
the tools that can make them if you have never had to do anything like
this before. However, for any reasonably experienced website maintainer,
this is probably the sort of issue that gets thrown at them occasionally
(in some cases very regularly) and it's good practice to get used to
using the sort of tools that can be used to sole such issues.
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|
Re: why php echo does not show up in HTML? [message #181685 is a reply to message #181675] |
Sat, 25 May 2013 00:06 |
Scott Johnson
Messages: 196 Registered: January 2012
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 3:49 PM, Denis McMahon wrote:
> On Fri, 24 May 2013 07:53:52 -0700, steve nospam wrote:
>
>> I can;t configure or change the web server. As I said, I use a web
>> hosting company. I am on a shared sever used by 100's others on the main
>> server.
>>
>> I can't call my hosting company talk to tech support and tell to please
>> edit the server config files for me and see if this will work.
>
> OK, so here's a list of other things you can not do:
>
> - You can not change the server so that it processes htm files as php
> files.
>
> Here's a list of things you can do:
>
> + You can download all the files from the server webroot to your local
> machine to bulk edit them
> + You can use tools such as sed to change every local url from .htm
> to .php
> + You can rename all the .htm files to .php files
> + You can automate the redirection of requests to *.htm to serve up the
> *.php files instead
> + You can upload all the fixed files to the server webroot
>
> External and existing search engine links will still work, because
> requesting the old .htm file will get the new .php file automatically.
>
> This is not a technically difficult fix, although you may need to spend a
> bit of time on getting to grips with the changes that need to be made and
> the tools that can make them if you have never had to do anything like
> this before. However, for any reasonably experienced website maintainer,
> this is probably the sort of issue that gets thrown at them occasionally
> (in some cases very regularly) and it's good practice to get used to
> using the sort of tools that can be used to sole such issues.
>
+1
|
|
|
Re: why php echo does not show up in HTML? [message #181688 is a reply to message #181649] |
Sat, 25 May 2013 03:59 |
gordonb.aykca
Messages: 1 Registered: May 2013
Karma: 0
|
Junior Member |
|
|
> That doesn't mean you can't change the configuration for your portion of it.
>
>> I can't call my hosting company talk to tech support and tell to
>> please edit the server config files for me and see if this will work.
>
> No, that's true, you can't. Fortunately, you don't need to. You should be able to do everything
> you need in the .htaccess file in your web root directory. You possibly will need to add a
This presumes that the hosting company has not put the directive
"AllowOverride None" in their configuration for your site. (For
Apache 2.3.9 and later, this is the default). It speeds up serving
web pages slightly by never looking for .htaccess files at all.
Therefore, you can't do redirects in .htaccess . If you discover
that your hosting company does this and they won't budge, find
another hosting company.
I recall trying to help some friends dealing with a hosting company
paranoid about security, at least for cheap/free accounts. One
official way to close your account was to upload a .htaccess file
(containing anything at all, or nothing at all). Your account would
be gone within an hour. So would all the other accounts using the
same payment account. And no, you couldn't get it back, except
perhaps by using a fake name and different domain name and payment
account. This was long ago and they offered essentially NO active
content or PHP except a hit counter CGI they provided.
You *CAN* do a redirect with pure HTML (done in the user's browser):
<HEAD>
<META HTTP-EQUIV="refresh" CONTENT="1;URL=http://mysite.com/path/foobar.php">
</HEAD>
|
|
|
|
Re: why php echo does not show up in HTML? [message #181698 is a reply to message #181688] |
Sat, 25 May 2013 13:22 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On 5/24/2013 11:59 PM, Gordon Burditt wrote:
>> That doesn't mean you can't change the configuration for your portion of it.
>>
>>> I can't call my hosting company talk to tech support and tell to
>>> please edit the server config files for me and see if this will work.
>>
>> No, that's true, you can't. Fortunately, you don't need to. You should be able to do everything
>> you need in the .htaccess file in your web root directory. You possibly will need to add a
>
> This presumes that the hosting company has not put the directive
> "AllowOverride None" in their configuration for your site. (For
> Apache 2.3.9 and later, this is the default). It speeds up serving
> web pages slightly by never looking for .htaccess files at all.
> Therefore, you can't do redirects in .htaccess . If you discover
> that your hosting company does this and they won't budge, find
> another hosting company.
>
> I recall trying to help some friends dealing with a hosting company
> paranoid about security, at least for cheap/free accounts. One
> official way to close your account was to upload a .htaccess file
> (containing anything at all, or nothing at all). Your account would
> be gone within an hour. So would all the other accounts using the
> same payment account. And no, you couldn't get it back, except
> perhaps by using a fake name and different domain name and payment
> account. This was long ago and they offered essentially NO active
> content or PHP except a hit counter CGI they provided.
>
> You *CAN* do a redirect with pure HTML (done in the user's browser):
>
> <HEAD>
> <META HTTP-EQUIV="refresh" CONTENT="1;URL=http://mysite.com/path/foobar.php">
> </HEAD>
>
Yes, but any hosting company which does that won't be in business for
long. For instance, most CMS's depend on being able to use mod_rewrite.
Doing it in HTML requires maintaining a whole set of additional files.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|
Re: why php echo does not show up in HTML? [message #181708 is a reply to message #181627] |
Sun, 26 May 2013 14:02 |
Richard Yates
Messages: 86 Registered: September 2013
Karma: 0
|
Member |
|
|
On Fri, 24 May 2013 06:20:03 -0700 (PDT), steve nospam
<steve(dot)nospamm(at)gmail(dot)com> wrote:
> I want to use php call to include common HTML code into an html page,
> but can't use php from HTML? what is the deal here? So, how do people
> do this thing then?
I sympathize. I had a similar situation with a site with some html and
some php files. As i refined it and added features i found that pages
I thought would never need dynamic content did.
There are awkward workarounds, but best might be to just switch all
html files to php. Use a global search-and-replace to change all
instances of '.html' to '.php' and your internal links will all work.
If you need to make a few html redirect pages for folks that have
bookmarked the html links, all you need to redirect index.html is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Home</title>
<meta http-equiv="REFRESH"
content="0;url=http://www.yoursite.org/index.php"></HEAD>
<BODY>
</BODY>
</HTML>
|
|
|