- This topic is empty.
-
AuthorPosts
-
November 21, 2010 at 11:49 am #30764lonMember
First I apologize if this question is too basic for this forum, if it is just tell me to go away and I will without any hard feelings.
Can someone point me to something that explains how to properly use echo within a web page?
I am trying to password protect a directory on a website for someone who knows even less about the web and HTML then I do and I came upon the page:
https://css-tricks.com/easily-password-protect-a-website-or-subdirectory/
It says I can get the path information needed by “echo(ing) out a phpinfo(); on a page in that directory” but I have not been able to get the echo statement to work. I know I am missing some fundamental knowledge here and would love to learn it.Thank you for your help and patience.
Lon.November 21, 2010 at 1:15 pm #73062Chris CoyierKeymasterYeah that’s probably an incorrect usage of “echo”. Just do:
phpinfo();
?>November 21, 2010 at 6:42 pm #72847lonMemberThank you for your help. Unfortunately I am still having problems setting and echoing out a variable.
Here is the code I am using that is not working:$path=phpinfo();
?>
Be Very Affraid
echo " the path is ".$path." ";That produces: “echo ” the path is “.$path.” “; ” on the web page.
Is there anything I can read on the proper use of echo itself?
Thank you again.November 21, 2010 at 6:46 pm #72848lonMemberI messed up. How Do I use those black boxes that you use to show your HTML?
Sorry.November 21, 2010 at 7:06 pm #72849RoxonMemberYou use:
or click the code icon.November 21, 2010 at 8:05 pm #72853AlexA.Participant$path = phpinfo();
?>
or
$path = phpinfo();
echo " the path is " . $path;
?>or
echo " the path is " . phpinfo();
?>
November 21, 2010 at 10:11 pm #72837lonMemberThis is driving me crazy. The code makes perfect sense to me, but nothing displays on the web page.
Be Very Affraid
$path = phpinfo();
echo " the path is " . $path;
?>
I have tried this above the HTML tag, within the head tags and within the body tags; but nothing displays.
What fundamental piece of information am I missing? Dam I feel stupid.
Thank you Chris, Roxon and Alex all! Your code could not be more clear, it makes perfect sense. I’m just missing something that everyone else seems to know.
(explicatives deleted)November 21, 2010 at 10:28 pm #72829TheDocMemberI don’t shoot me for asking the question, but I thought I’d ask the obvious – are you sure you are working on a page that can handle PHP?
For example, if you’re editing an HTML page (page-name.html), without some fancy .htaccess trickery your PHP won’t actually work.
November 22, 2010 at 5:01 am #72775Rob MacKayParticipantOk.
phpinfo(); is a function that gives you all the information about the PHP installation on your server. It tells you everything you can and can’t do by default – and lets you know if you need to turn anything on or off depending on what features you have.
If you create a file called phpinfo.php then add
phpinfo();
?>Then if you navigate to it you will be shown a page with a table of info on it :) phpinfo() won’t return a path when you use it as you are trying to, but it will show you a path within the mountain of other info it gives you.
So when you echo out a phpinfo – that’s what that means. It will give you the info you need automatically.
November 22, 2010 at 8:27 pm #72642lonMemberDear TheDoc, I do not find any fault for you asking if the environment can handle PHP. It definitely was the question to ask. Thank you for trying to help me. You are greatly appreciated.
Dear robSkiwarrior, Thank you Thank you thank you! You explained exactly the underlying idea I was missing. I did as you suggested and got the table you said I would. I was able to find the path info and have gotten the password protection to work. Did I say thank you? Thank you! You are definitely the skiwarrior of my heart.
I am in your debt,
Lon.November 23, 2010 at 3:08 am #72612Rob MacKayParticipanthaha no probs :)
December 11, 2013 at 10:44 am #158188stensevenParticipantI think it is useful to point out that each code example shown above contains an error, specifically the first space between the outward carat < and the question mark ?
< (word space here) ?php does not work.
December 11, 2013 at 11:33 am #158195__ParticipantSince everyone was doing it, I think it may have been a problem with how the forums parsed posts with code in them (I remember that we had seemingly endless troubles with that, for a time. It seems to work just fine now, though).
<?php
-
AuthorPosts
- The forum ‘Other’ is closed to new topics and replies.