Advanced Search

Results 1 to 10 of 10

Thread: Code Area

  1. #1
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Code Area

    Ok, I am trying to figure out how to make something allow this to be put in a page:
    PHP Code:
    <?php
    echo 'Some Code';
    ?>
    I see it used to post tutorials a lot and I am making a tutorial management script with authoring capabilities, but I can't figure this out. I would appreciate any help. Thanks in advance
    Thanks DD, you saved me countless times

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    That code is VERY basic and will simply be parsed as "Some Code", with no linebreaks, etc., just placed where it is in the source code of the html.
    What exactly is unclear about using that?

    To use PHP at all, you must 1. have it installed on the server, 2. have it enabled, 3. have it parsed as PHP, meaning that the page must end with .php or you must have another extension set (perhaps with .htaccess) to be parsed as php, but that is usually more trouble than it's worth.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Actually, I think he was referring to making a tutorial type page with blocks that look like so:

    PHP Code:
    <?php
     
    echo 'This is the code snippet that is highlighted and displayed';
    ?>
    (or anything placed between the [PHP] tags in this forum as well as some other forums).


    The way that is accomplished is by using highlight_string() and displaying that on the page in between whatever other tags you want (<div>, <table>, etc).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  4. #4
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thats exactly what I need, testingsite. Just one more thing, do you have any suggestions on how I can implement this in a user friendly manner. Like some way of it reading what part should be code and then putting highlight_string() around it? Thanks for the help
    Thanks DD, you saved me countless times

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Probably the best way would be to use bbcode (any tags that you specify), then use either preg_replace or str_replace to create the proper formatting for that tag.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Ah, very interesting.
    I thought that question was too easy.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Quote Originally Posted by djr33 View Post
    I thought that question was too easy.
    I thought so too the first time I read it. I went back and reread it a few more times just to comprehend it.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  8. #8
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry about not making it to clear. Thanks for all the help
    Thanks DD, you saved me countless times

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,156
    Thanks
    262
    Thanked 690 Times in 678 Posts

    Default

    Ha, well, I know you've worked with PHP before, so that's why I went into the detail on possible issues, though I couldn't figure out why you were back to such basics

    As for the latest question, BB code is a good answer.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    266
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Ha, well, I know you've worked with PHP before, so that's why I went into the detail on possible issues, though I couldn't figure out why you were back to such basics

    As for the latest question, BB code is a good answer.
    Yeah, I read it again myself and saw how it came across wrong.
    Thanks DD, you saved me countless times

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •