Page 1 of 1

outputtiing text help still needed

Posted: Tue Aug 29, 2006 10:47 am
by kebo
How do I make php output "<td></td>" ?

When I use

Code: Select all

echo "<td></td>";
I guess it treated as an html string and I get no output.

thanks, second day learning php
kevin

Posted: Tue Aug 29, 2006 10:51 am
by darodesign
What do you mean with no output ? You can't see anything 'cause the table data fields are empty! Looked in the Website Source ? ( At the viewing with your Browser )

Posted: Tue Aug 29, 2006 10:51 am
by Oren
You mean that you want to see on the screen with your browser:

<td></td>

Is that what you mean?

Edit: If that's what you want, then use this code:

Code: Select all

echo htmlspecialchars('<td></td>');

Posted: Tue Aug 29, 2006 10:52 am
by kebo
Oren wrote:You mean that you want to see on the screen with your browser:

<td></td>

Is that what you mean?
yes exactly

Posted: Tue Aug 29, 2006 10:55 am
by Oren
I edited my previous post, take a look :wink:

Posted: Tue Aug 29, 2006 10:56 am
by kebo
cool thanks oren...

^5

kevin

Posted: Tue Aug 29, 2006 2:55 pm
by kebo
so that works to directect the output to the browser, but now I would like to direct the output to a file. So when I use

Code: Select all

$fo = fopen($fname, "w");
echo fwrite($fo ,"<td></td> ");
the file contains <td></td>, but if I try

Code: Select all

$fo = fopen($fname, "w");
echo fwrite($fo ,"<HTML> ");
the file is empty, and when I use

Code: Select all

$fo = fopen($fname, "w");
echo htmlspecialchars('<HTML>');
the < turns into < and the > turns into >.
Can anyone explain this in a brief nutshell or explain how to write <HTML> to a file?
thanks
kevin

Posted: Tue Aug 29, 2006 3:15 pm
by Oren
Well pal, I could tell you what your mistakes are, but this isn't really going to help. You need to take a good book and start reading.
You know the old saying about the man and the fish...

Posted: Tue Aug 29, 2006 3:20 pm
by kebo
Oren wrote:Well pal, I could tell you what your mistakes are, but this isn't really going to help. You need to take a good book and start reading.
You know the old saying about the man and the fish...
Well i certainly would agree about the fish part, but in the real world, if someone works for me and spends 2 days in a book trying to find information they can get in 2 minutes by asking....i'd fire them

Posted: Tue Aug 29, 2006 3:52 pm
by MaxInfinity
thats the best answer to a remark I've ever heard.

The whole point of forums is to help yourself and other people and if people don't want to help and show off their coding skills, they should not be on a forum.

None of that was directed at oren either, I talking in general. The worst advice is use the search button, on a good forum this will bring up 10000 posts 90% of which, have nothing to do with what you searched for. Yes I know its annoying to be asked the same question over and over again, but until a search button works properly, surely its easier and quicker to type a link to the post with the correct info, than to type try using the search button.

On the other side of the coin, the people asking for help should at least try to write the code they need and if they get stuck, post the code for someone to look at, and point you in the write direction. My php mysql coding skills are dire to say the least, but I can still manage a very decent page with a little research and the odd question here and there.

JMHO

Posted: Tue Aug 29, 2006 3:56 pm
by Luke
well he should at least read the manual page for htmlentities: http://fr3.php.net/manual/en/function.h ... lchars.php

Once you read that page... the whole thing (not including user comments of course) and you still are confused... I'll help you.

Posted: Tue Aug 29, 2006 4:16 pm
by Oren
I don't have much to say as I made my point very well (I believe) with the fish saying.

Anyway, try this instead:

Code: Select all

fwrite($fp ,'<td></td>');
(Without the 'echo')

If you are using PHP 5, just use this:

Code: Select all

file_put_contents($file_name, $data);