GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Jul-2006, 15:09
SumOking SumOking is offline
New Member
 
Join Date: Jun 2006
Posts: 6
SumOking is on a distinguished road

the content in MY page


Hi Forum,

I want to include text in my page. The text sometimes might have
some format - like line breaks and I don't want to worry too much about things like: ' or " ....

how do I do that using include (or something similar)

htmlentities(include("content.txt"), ENT_QUOTES);

includes it, but if content.txt contains html code it still su%§$
Well I guess there are a lot of ways. I want to fill the plain
text from .txt files in css boxes.

Greetings

Dan
  #2  
Old 28-Jul-2006, 16:04
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: the content in MY page


What is the question?

If you want to simply strip markup from the string (content), you may want to consider strip_tags()?
  #3  
Old 28-Jul-2006, 18:59
SumOking SumOking is offline
New Member
 
Join Date: Jun 2006
Posts: 6
SumOking is on a distinguished road

Re: the content in MY page


Quote:
Originally Posted by JdS
If you want to simply strip markup from the string (content), you may want to consider strip_tags()?

no, I don't want to strip the tags. I want to include a plain text file (*.txt) in the body of my page. All characters (in the text file) which have HTML character entity equivalents have to be translated into these entities. In case the text file contains html code, I don't want the code/tags to be removed but
converted (e.g.: </B> converted to &lt;/B&gt; )

Thanks

Dan
  #4  
Old 28-Jul-2006, 19:42
SumOking SumOking is offline
New Member
 
Join Date: Jun 2006
Posts: 6
SumOking is on a distinguished road

Re: the content in MY page


This works

<?php
$content = file_get_contents('content.txt');
echo htmlentities($inhalt, ENT_QUOTES); ?>


.......BADcode.......htmlentities(include("content .txt"), ENT_QUOTES);


Tanks

D
  #5  
Old 28-Jul-2006, 21:34
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough

Re: the content in MY page


If this is for a web page, you just need htmlspecialchars.

Because you didn't supply example content from content.txt, and what you hope to see on the web page, it's hard for me to understand what you're asking.

The problem with htmlentities/htmlspecialchars is that it will translate & into &amp;, which affects any html character entity already inside content.txt.

A decent way of maintaining the character entities in your web page is to use preg_replace, like this:

PHP Code:

<?php
$content = file_get_contents( 'content.txt' );
echo preg_replace( "/&amp;(#[0-9]+|[a-z0-9]+);/i", "&$1;", htmlspecialchars($content, ENT_QUOTES) );
?>

  #6  
Old 30-Jul-2006, 11:46
SumOking SumOking is offline
New Member
 
Join Date: Jun 2006
Posts: 6
SumOking is on a distinguished road

Re: the content in MY page


Quote:
Originally Posted by JdS
The problem with htmlentities/htmlspecialchars is that it will translate & into &amp;, which affects any html character entity already inside content.txt.

There is no problem with & and &amp;using my code!
I don't know why.

But I have an other related question:
whenever I use letter-spacing:0.05em to format
a class of text IE doesn't execute <br /><br /> in the text.
It just makes a single <br />. Firefox works fine.

same code, letter-spacing:0.05em (plain text)

IE makes:
bla*
bli**
blupp

Firefox makes:
bla*
bli**

blupp

*line brake(<br />) ** 2line breaks (<br /> <br />

If anybody knows a tutorial about text-screen-layouts
(how to get the best readability), I would be grateful!
 
 

Recent GIDBlogFirst week of IA training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Google AdSense tips to earn money amigo AdSense Forum 30 17-Mar-2008 09:02
Bad, bad Google update! JdS Search Engine Optimization Forum 18 12-Nov-2005 21:41
Loading a php page in an iframe from javascript Clive73 Web Design Forum 0 18-May-2005 06:10
[script] E-mail webmaster error page BobbyDouglas PHP Code Library 0 19-Aug-2003 20:10

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 20:29.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.