Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Junior Member
    Join Date
    Jun 2007
    Posts
    4
    Member #
    15402
    I am interested in learning to use PHP fully and well, and I realise it is one of the most badly used languages on the net. However, my question is this.
    On this forum I saw someone use an 'include' tag of some description. He said something about using it to create a sidebar. If I create an HTML document (and save it on the web server in the correct place etc) containing the side bar, in the right position, then use this tag (in an HTML document saved as .php), will that make the sidebar appear as it should? instead of typing it in every time.
    Also if you could include what the tag looks like that'd be great.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Yes, that will work as you say. The tag is this:
    PHP Code:
    <?php include('other_file.html'); ?>

  4. #3
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    However, being a language construct (something not particularly important now), you can also call it without the braces. So...

    PHP Code:
    <?php
    include "other_file.html";
    ?>
    Is equivalent to Shadowfiend's code above. Another one you'll get to know and is a language construct is echo. An echo is pretty much just printing out a line of plain HTML (another function called print() does this too, but usually you'll want to echo).

    Important: Before you start going off track, don't call them "tags", call them functions. It's easy to confuse it with HTML tags, and I'm worried some people looking at this will think "oh, if I put in <include("file.html") /> I'll include the file!" or something.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, if you write an appropriate preprocessor, it will

  6. #5
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,715
    Member #
    5580
    Liked
    717 times
    QUOTE:
    ".... it is one of the most badly used languages on the net."

    I'm not sure what that means. Any programming language can
    be poorly coded ... PHP can't be singled-out as a badly used language.

    What you see happening is that PHP is getting to be so widely used and
    many people cut and paste code from any of the millions of scripts available.
    If there are more PHP scripts ... there is bound to be more poorly done scripting.

    If Chevrolet dominated the freeways with cars, there would be more accidents
    involving Chevrolets ... sort of the same thing.

    Once you see the power of mixing XHTML and PHP (or AJAX applications), you'll
    soon see why it's become so popular. Static web pages are quickly becoming
    a thing of the past.


  7. #6
    Senior Member planetgman's Avatar
    Join Date
    Jun 2005
    Posts
    569
    Member #
    10406
    Steax, is that a bowl of ice cream in your avatar? hahahaha

    G
    GMan

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Well, it's generally acknowledged on the web that the one of the few other languages in widespread use that can produce more unmaintainable spaghetti code more quickly than PHP is Perl.

    PHP makes it easy to produce bad code, much like Perl does. Doesn't make it a bad language, necessarily. Just means it's really easy to produce bad code with it. Really, I think Ruby suffers from the same problem; we just haven't had the influx of people who will produce the spaghetti code yet.

  9. #8
    Junior Member
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    25
    Member #
    15371
    While I do use PHP to create Ajax-enabled web sites, I am very interested in Ruby on Rails which has an ajax-enabled framework.
    ---------------------------------------
    RalphF
    Domains & $4.99 Web Hosting
    http://www.GoldRushWebHosting.com

  10. #9
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    rfresh -- please get rid of the hand-added signature on your posts. The restriction that you must reach a certain level of membership in the community before being allowed a signature is in place for a reason.

    That said -- PHP has its own frameworks that support AJAX out of the box, such as Symfony and CakePHP.

    Rails, however, kicks ***, and I'm a huge fan and wouldn't trade it for anything right now

  11. #10
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    IMO, PHP is a lot easier for people used to languages like C++ or Java. RoR, in my opinion (I have to keep saying that or else people'll stomp on me) is better for people new to the playing field.

    Steax, is that a bowl of ice cream in your avatar? hahahaha
    It's a composite of angle wings, a suit of armor, sunglasses, and ice cream. Courtesy of Icon Buffet.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:24 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com