• Help
  • Search
  • Login
  • Register
  • Home

Forum: web design and graphics community

Celestial Star Forum > Web Development > Coding > A Quick Question...
Pages: [1]
« previous next »
  Print  
Author Topic: A Quick Question...  (Read 643 times)
SilentSerenityXx
Angeling
*
Posts: 2



View Profile WWW
A Quick Question...
« on: August 24, 2006, 10:13:12 AM »

Sorry if this is really simple, but does anyone know how, in a .php file, to show PHP code within a textarea without it being compiled and interpreted?  Thanks!  =)
Logged

img]http://img.photobucket.com/albums/v623/mysticwater45/final.jpg[/img]


You can close your eyes to things you don't want to see, but you can't close your heart to things you don't want to feel.
assie-chan
Retribution
***
Posts: 156



View Profile WWW
A Quick Question...
« Reply #1 on: August 24, 2006, 12:40:01 PM »

Ha ha, very simple. Replace any < with &lt; and > with &gt; And usually, instead of <textarea> I use, <code> since textareas don't change the escape codes.

You can see an example of how I do it here: http://vitae.infinite9.net/index.php?Key=Tutorials&SubKey=SplashGate
Logged

"If Xerxes was two men, and he was the only two men alive, I wouldnt allow him/them to have intercourse."
Vangs
Administrator
Valkyrie Randgris
*****
Posts: 525



View Profile WWW
A Quick Question...
« Reply #2 on: August 24, 2006, 01:17:48 PM »

Actually thats only how you prevent tags from being displayed, it doesn't answer her question of how to open a php file to be edittable.

The coding is as follows:

Code:
$file = file_get_contents("file.php");
$file = htmlspecialchars("$file");
$file = str_replace("\n","<br>",$file);


Then just set the textarea content to echo $file. Of course thats a very basic way of displaying it, it works though. Although you will still need to create a script to write the new contents to the file. So in your form processing do this:

Code:
$newcontent = $_POST['content'];

$handle = fopen("file.php", 'w');
fwrite($handle, $newcontent);
fclose($handle);


Change $_POST['content'] to whatever you name the textarea, and change file.php to your file.
Logged

SilentSerenityXx
Angeling
*
Posts: 2



View Profile WWW
A Quick Question...
« Reply #3 on: August 25, 2006, 06:02:40 PM »

Cool, thanks so much guys!  =)
Logged

img]http://img.photobucket.com/albums/v623/mysticwater45/final.jpg[/img]


You can close your eyes to things you don't want to see, but you can't close your heart to things you don't want to feel.
Pages: [1]
  Print  
« previous next »
 
Jump to:  

  • Welcome, Guest
  • Members login
  • Register for free

General

  • General
  • New members
  • Announcements
  • Support / Suggestions

Art boards

  • Creative mediums
  • Requests and offers
  • Tutorials
  • Celestial Star tutorials

Web development

  • Coding
  • Web design
  • Advertisements / affiliation

Off-topic

  • The non-sense
  • Ententainment

Go up
eXTReMe Tracker
  • Valid XHTML
  • Valid CSS
Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC | Seo4Smf v0.2 © Webmaster's Talks
Loading...