Jump to content

quick help


Recommended Posts

I need some very quick help. I need to just figure out how to make text show, no matter what language. It hink this is xhtml. I want to be able to display code in a browser, no matter what language, asp, jsp, html, php, javascript, whateverTO where when I write tutorials I can have code examples, and I want the code to print out to the screen without actually parsing, or running. Advice anybody?

Link to comment
Share on other sites

huh? Please explain a little bit better.. you want like to have some php and have it parse, without the page refreshing or anything? Use ajax.. I can help you out with this, if this is in fact what you want...

Link to comment
Share on other sites

No I mean like being able to display code directly to the browser without it getting read as a language.Like if i write any tutorial, for xhtml, css, javascript, ajax, php, asp jsp, there has to be a way to show code examples, of the language without actually running the language.Like if I was explaining echo I would want to SHOW to the people<?phpecho "hello world";?>without it actually running the script but instead show the whole block of code as text, the same with xhtml, javascript, or css tutorials.

Link to comment
Share on other sites

yes but in an original and organized viewing format. Like with this forum, when you use the bbcode


tags everything in between those are preserved in there original language, like asp, jsp, php, xhtml, css, javascript or whatever else, in a displayable format. But I can't get it to do that on the screen, I tried pre tags, and other stuff. Like when you use php highlight function it makes a whole file display as programming instead of running the script, but I need it to do that in small sections as examples during tutorials.

Link to comment
Share on other sites

ahh, you want indents to? Pre should do that, but ive had bad experiences with that lol. ummmm, you could take the long way and use a css to do text-indent (takes px, or em). But that would take a while..

Link to comment
Share on other sites

Not text indenting either, and not pre, I tried using that before. Ok picture this, you use any type of language, XHtml, CSS, Javascript, PHP, asp, jsp, ajax, whatever.When you put down xhtml, and css you don't see the programming in the browser, you just see the results of itNow when you look at for instance the tutorials on w3schools.comthey have code snippets out of all the languages, asp, jsp, javascript, xhtml, and other stuff showing code examples, or things like that, I need to be able to do that, I am writing tutorails, and it'll be on all languages, I need a way to show code examples as I go, like the do on w3schools.

Link to comment
Share on other sites

you want to be able to show code in the browser.. so its not parsed. I dont get it. for the beginning tag (<) you put < in place of it, for the end tag (>) you put >! Do you want it in like a code box or something?

Link to comment
Share on other sites

sort of.A general purpose solution.Like I wanted to be able to write tutorials on all languages.If I am explaining javascript I need<script type="text/javascript">document.write(helloworld);</script>sorry if it looks dumb I have been doing so much php lately, I have to refresh on my javascript, but that is basically what I mean. I am writing tutorails, and it will be using all languages, some tutorials on php, some asp, jsp, xhtml, css, javascript, ajax, whatever else, I need to show the code, in the browser. All tags and everything,like the codeblocks they show as examples on w3schools, or something similar.

Link to comment
Share on other sites

okay, to replace all the tags so they show do this:< = <> = >(thats for anything that has those). and since /* */ and those comments are only parsed when they are in the coding lanuage, not in html, you just write them along with the rest of the code. but if you are using the get method (?page=1, ?page=2, etc..) then just escape all slashes by doing this:\/ :) and escape all escapes like this, \\ lol. Its as simple as that!Wow, im suprised I knew this. Im guessing your out of college and like 24-27? Im 13 :) 14 on sept. 14!! woohoo!!

Link to comment
Share on other sites

nope, thats the only way. sucks doesnt it! But most decent editors you can get have the search and replace functions, so write your codes then search and replace them for those.Notepad does this.. but, if you arent using the get method, all you need to do is change the < and >

Link to comment
Share on other sites

That sucks it makes me not even want to write them, I thought there was a way to do this. I am thinking is there a way I can create something in php, so I can feed it whatever and it outputsLike can I modify the highlight function that is exactly what I want something like that.I won't be using get or postI will be displaying it direclty just inside tutorials I am creating.

Link to comment
Share on other sites

Pre code and samp, I tried them all none of them work. If I put <pre

<?php// code here?>

You see there were it shows <?php?> as well as the code, when I use pre, samp, or code all it does is run the php code in between anyway, I need it to actually SHOW the code itself, as I said like they use for the tutorials. I was hoping to not HAVE to use html entities everytime I wanted to put in <?phpand ?> But I don't know, nothing else is seeming to work?

Link to comment
Share on other sites

Oh. Well if you are embedding PHP on a web page, regardless of if it is in any HTML tag, it will get executed by the PHP parser before any output gets sent. The parser doesn't exclude code inside any HTML tags, it doesn't even look at the HTML. You either need to escape the brackets, or don't put it on a .php page! PHP also has the highlight_string function.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...