Announcement

Collapse
No announcement yet.

PHP.net

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP.net

    Ok, I have seen all of these awesome websites that were completely made in PHP and they look great, but is it PHP that makes their news?

    I dont understand how each page follows the same layout and design, but they update the design and layout of every single page at the same time. Currently only knowing HTML, XML, CSS, Perl, and some Java I am confused with this concept. Well, what the hell are they doing to do this?

  • #2
    ahhh... keywords: "at the same time"

    They prolly have a live site (which you see), and a developement site (where they design the next layout). Once a layout is complete, they can move it to the live site fairly easily and it appears to have changed 'all of a sudden.'

    Comment


    • #3
      Ease to understand. First design the template by normal HTML with DHTML or JScript... Then you have a template, so you use PHP to retrieve data which you wanna use from database (mostly mySQL) and fill it into the template.... look like this.


      I have the template:
      PHP Code:
      <b>hi there</b
      Then I replace "hi there" with PHP code:
      PHP Code:
      <b><? print $text ?></b>
      (variable $text is generated by PHP)

      Then I change the template if I like, to
      PHP Code:
      <u><? print $text?></u>
      for example... Then all the text become underline instead of bold!!!! Voila....

      Comment


      • #4
        So your saying that once I have created a website with PHP and MySQL and I do decide to change that Bold to an Underline that I will have to edit every single page to change it to underline? What happens if I make a typo that is on every page? What would I do?

        Is there any way that there will be a templete that all pages use and if you update that page it will update all of the pages along with it, sort of like CSS text formatting.

        Comment


        • #5
          templates are a key element in producing a dynamic site. You can have just 1 template and add everything dynamically using a mysql database. so like the <b> thing frzzman was saying is you can have 1 template and just edit that one file to get the look for ALL your pages.

          Comment


          • #6
            I'll see if this clears anything up... This is the source code for PHP.net's index.php:

            PHP Code:
            <?php
            /* if you're reading this, it isn't because you've found a security hole.
               this is an open source website. read and learn! */

            header("Cache-Control: public, max-age=600");

            require_once 
            'prepend.inc';

            $SIDEBAR_DATA '
            <br>
            <h3>What is PHP?</h3>

            <p>
            <acronym title="recursive acronym for PHP: Hypertext Preprocessor">PHP</acronym>
            is a widely-used general-purpose scripting language that is
            especially suited for Web development and can be embedded into HTML.
            If you are new to PHP and want to get some idea
            of how it works, try the ' 
            make_link("/tut.php""introductory tutorial") . '.
            After that, check out the online ' 
            make_link("/docs.php""manual") . ',
            and the example archive sites and some of the other resources
            available in the ' 
            make_link("/links.php""links section") . '.
            </p>

            <p>
            PHP is a project of the ' 

            make_link("http://www.apache.org/","Apache Software Foundation") . '.
            </p>

            <h3>' 
            make_link("/thanks.php""Thanks To") . '</h3>
            &nbsp; ' 
            make_link("http://www.easydns.com/?V=698570efeb62a6e2""easyDNS") . '<br>
            &nbsp; ' 
            make_link("http://www.pair.com/""pair Networks") . '<br>
            &nbsp; ' 
            make_link("http://www.rackspace.com/?supbid=php.net""Rackspace") . '<br>
            &nbsp; ' 
            make_link("http://www.synacor.com/""Synacor") . '<br>
            &nbsp; ' 
            make_link("http://vasoftware.com/""VA Software Corporation") . '<br>
            <h3>Related sites</h3>
            &nbsp; ' 
            make_link("http://www.apache.org/""Apache") . '<br>
            &nbsp; ' 
            make_link("http://www.mysql.com/""MySQL") . '<br>
            &nbsp; ' 
            make_link("http://www.postgresql.org/""PostgreSQL") . '<br>
            &nbsp; ' 
            make_link("http://www.zend.com/""Zend Technologies") . '<br>
            <h3>Community</h3>
            &nbsp; ' 
            make_link("http://www.linuxfund.org/""LinuxFund.org") . '<br>
            &nbsp; ' 
            make_link("http://www.osdn.org/""OSDN") . '<br>

            <h3>Contact</h3>

            <p>
            Please submit website bugs in the ' 
            .
            make_link('http://bugs.php.net/''bug system') . '.
            </p>
            <p>
            You can contact the webmaster at ' 

            make_link('mailto:[email protected]''[email protected]') . '.
            </p>
            '
            ;

            $fp = @fopen("backend/events.csv",'r');
            if(
            $fp) {
                
            $cm=0;
                while(!
            feof($fp)) {
                    list(
            $d,$m,$y,$url,$desc,$id) = fgetcsv($fp,8192);
                    if(
            $cm!=(int)$m) { 
                        if(
            $cm$RSIDEBAR_DATA.= "<br />\n"
                        else 
            $RSIDEBAR_DATA.='<h3>Upcoming Events<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="submit-event.php">[add event]</a></h3>';
                        
            $cm = (int)$m;  
                        
            $RSIDEBAR_DATA .= "<h4>".strftime('%B',mktime(12,0,0,$cm,$d,$y))."</h4>\n"
                        unset(
            $seen);
                    }
                    if(!
            $seen[$desc]) {
                        
            $RSIDEBAR_DATA .= "$d. <a href=\"cal.php?id=$id\">$desc</a><br>\n";
                        
            $seen[$desc] = true;
                    }
                }
                
            fclose($fp);
            }

            commonHeader("Hypertext Preprocessor");
            echo 
            "\n<!--$MYSITE-->\n";
            ?>

            <?php print_link("http://photos.jdimedia.nl/phpdoc/"make_image("brain.gif""PHPDoc Brain""right") ); ?>

            <h1>PHP Documentation Team Meeting</h1>
            <p>
            <font class="newsDate">[13-Mar-2002]</font>
            The <?php print_link('http://www.php-ev.de/documents/phpdoc/protocol.html''notes from the PHP Documentation Team Meeting'); ?> (Stuttgart, March 8th-10th) are now available.
            <?php print_link('http://photos.jdimedia.nl/phpdoc/''Pictures of the event'); ?> are also online.
            </p>

            <?php echo hdelim(); ?>

            <h1>PHP Security Update - Windows Version</h1>
            <p>
            <font class="newsDate">[12-Mar-2002]</font>
            Following up from the previous annoucement, PHP 4.1.2 has been released for windows. The delayed release is due to 
            the fix of a further security issue only relating to the PHP for Windows version. More information on this change can
            be found <?php print_link('/release_4_1_2_win32.php''here'); ?>. All PHP - Windows users are encouraged to upgrade to
            the <?php print_link('/downloads.php''latest version'); ?>.
            </p>

            <?php echo hdelim(); ?>

            <h1>PHP Security Update</h1>
            <p>
            <font class="newsDate">[27-Feb-2002]</font>
            Due to a security issue found in all versions of PHP (including 3.x and 4.x), a new version of PHP has been released.
            Details about the security issue are <a href="http://security.e-matters.de/advisories/012002.html">available here</a>.
            All users of PHP are strongly encouraged to either upgrade to <a href="/downloads.php">PHP 4.1.2</a>, or 
            install the patch (<a href="/downloads.php">available for PHP 3.0.18, 4.0.6 and 4.1.0/4.1.1)</a>.
            </p>

            <?php echo hdelim(); ?>

            <?php print_link("http://weblabor.hu/php-doc-chm"make_image("chmhelp.gif""CHM""right") ); ?>

            <h1>Fourth sample of 'PHP Manual CHM Edition'</h1>

            <p>
            <font class="newsDate">[16-Feb-2002]</font>
            We released the fourth sample of the new CHM Edition. It was
            a long time to release this version, as we revamped the design,
            optimized the HTML code, made the pages stretch to any window
            size, switched to use XSLT style sheets instead of DSSSL to
            generate the pages, and coded many improvements and fixes.
            </p>

            <p>
            <?php print_link("http://weblabor.hu/php-doc-chm""Try out the new CHM Edition"); ?>,
            and send us your feedback to our
            <?php print_link("mailto:[email protected]""dedicated mailing list"); ?>.
            </p>

            <?php echo hdelim(); ?>

            <h1>PHP-GTK 0.5.0 released</h1>

            <p>
            <font class="newsDate">[24-Jan-2002]</font>
            <?php print_link("http://gtk.php.net/""PHP-GTK"); ?> has reached version
            0.5.0, also known as <em>"monday starts on saturday"</em>. The version number
            was bumped from 0.1.1 to this one to indicate that PHP-GTK is now a fairly
            mature and stable extension and can be used for a variety of applications
            (just look on <?php print_link("http://www.freshmeat.net/""Freshmeat"); ?>).
            </p>

            <p>
            Also taking this opportunity, we would like to ask if some of you would consider
            helping out with PHP-GTK documentation. It would be a great way to learn this
            exciting extension and also contribute to the project.
            </p>

            <?php echo hdelim(); ?>

            <?php print_link("/usage.php"make_image("stats-small.gif""PHP Usage Stats""right") ); ?>

            <h1>Usage stats for December available</h1>

            <p>
            <font class="newsDate">[09-Jan-2002]</font>
            <?php print_link("http://www.netcraft.com/""Netcraft"); ?> and
            <?php print_link("http://www.securityspace.com/s_survey/""SecuritySpace" ); ?> have
            published the <?php print_link("/usage.php""current results"); ?> for their Web
            Server surveys.
            <br clear="all">
            </p>

            <?php echo hdelim(); ?>


            <?php print_link("http://www.php-conference.de/2001/index_en.php"make_image("international_conference.gif""International PHP Conference 2001""right") ); ?>

            <h1>International PHP Conference slides available</h1>

            <p>
            <font class="newsDate">[10-Jan-2002]</font>
            You can find an overview of all slides of the sessions from the
            International PHP Conference 2001 on the
            <a href="http://www.phpconference.de/2001/slides_en.php">conference
            slides page</a>. It is still not too late to check out some photos
            from the conference:
            <ul>
                <li><?php print_link("http://www.photoalbum.nohn.net/PHPConference2001""Sebastian Nohn"); ?></li>
                <li><?php print_link("http://www.bttr.org/phpconf/""Ralf Geschke"); ?></li>
                <li><?php print_link("http://www.php-conference.de/2001/images/PHP_Konferenz/""Conference photos"); ?></li>
            </ul>
            <br clear="all">
            </p>

            <?php echo hdelim(); ?>

            <h1>PHP 4.1.1 Released!</h1>

            <p>
            <font class="newsDate">[26-Dec-2001]</font> Due to a few bugs in PHP 4.1.0, we
            decided to release <a href="/downloads.php">PHP 4.1.1</a>. The bugs that were
            fixed are not major ones but minor ones, which could be annoying if you get
            bitten by them.
            </p>
            <p>
            Our recommendation is that people who already upgraded to PHP 4.1.0 do
            not need to upgrade to PHP 4.1.1 unless they're experiencing one of the
            described bugs. Read the full
            <a href="/release_4_1_1.php">release announcement</a>.
            <br clear="all">
            </p>

            <?php echo hdelim(); ?>

            <p align="center"><a href="/news.php">Old News</a></p>

            <?php commonFooter(); ?>
            See how you can include certain things, and still use regular html...

            http://www.php.net/source.php?url=/index.php

            Comment


            • #7
              Im just wondering and I probably already know the answer, but is there anything special you can use with PHP if you are using XML to put it on a page?

              Are there certain DTDs that you have to use to use PHP on an XML page?

              Comment


              • #8
                XSLT
                http://www.webmasterbase.com/article.php?pid=28&aid=602

                Comment


                • #9
                  Sorry, but I am still lost on how these websites make "templetes" that every single page follows.

                  On the next version of my site, I basically want to have it so there is 1 templete for every news article, 1 templete for the main page, 1 templete for content pages, 1 templete for media pages, and thats about it. How do you make templetes that access text from a MySQL database. I am completely new to the world of PHP and MySQL and need a bit of help. How do they do that and how can I do that?

                  Does PHP.net really teach you everything that PHP can do, how did you learn it?

                  Comment


                  • #10
                    Originally posted by Seph

                    Does PHP.net really teach you everything that PHP can do, how did you learn it? [/B]

                    seriously once you know the code structure of php you only use php.net as a reference. It is a great tool and most would be lost without it.

                    Personally i learnt most of it by example...ill try to explain what i think you want to know...

                    ---

                    you have a main page right? on this html page you might have your header, your menu and then a box for the content that goes in there when you click on a menu item.

                    Instead of putting the news in this box you put PHP code in there that includes (include(), but there are many other ways of doing it) another smaller page which only contains content OR you do mysql routines to grab the info off a database.

                    There are many many ways of doing this but ill show you one way which includes small (content) pages into the bigger (template) one.

                    Code:
                    //---THIS IS YOUR TEMPLATE (index) PAGE---
                    
                    <html>
                    <head>
                    <title>Rrarrr</title>
                    </head>
                    <body>
                    
                    HEADER blah blah blah big fancy photoshop job....
                    
                    <table>
                    <tr>
                    <td>
                    <a href="?page=grass">Grass</a><br>
                    <a href="?page=menu2">Menu2</a><br>
                    <a href="?page=menu3">Menu3</a><br>
                    <a href="?page=menu4">Menu4</a><br>
                    <a href="?page=menu5">Menu5</a><br>
                    </td>
                    <td>
                    
                    <? 
                    $getpage = $page . ".php";
                    include($getpage); ?>
                    </td>
                    </tr>
                    </table>
                    Ok, say your website is at http://www.theconscience.net/index.php Now if you click any of your links (lets take "grass" for eg.) it will load the page http://www.theconscience.net/index.php?page=grass.

                    As you can see it is still loading index.php BUT it is also passing a variable though the URL to the page.

                    Now we look at the php include part.
                    note that $page is the ?page=grass you set in the URL therefore $page = grass.

                    $getpage is therefore equal to "grass.php".

                    so then it says include($getpage) which is therefore going to include into the page grass.php. (note that grass.php will have to be in the same directory as index.php unless you specify the directory in the path.

                    so then in grass.php you might have simply
                    Code:
                    <font color=red>I like grass</font>
                    and that is all that is in grass.php.

                    so then when the site is actually RUN by the end user they will see (ie their browser will interpret):

                    Code:
                    <html>
                    <head>
                    <title>Rrarrr</title>
                    </head>
                    <body>
                    
                    HEADER blah blah blah big fancy photoshop job....
                    
                    <table>
                    <tr>
                    <td>
                    <a href="?page=grass">Grass</a><br>
                    <a href="?page=menu2">Menu2</a><br>
                    <a href="?page=menu3">Menu3</a><br>
                    <a href="?page=menu4">Menu4</a><br>
                    <a href="?page=menu5">Menu5</a><br>
                    </td>
                    <td>
                    
                    <font color=red>I like grass</font>
                    
                    </td>
                    </tr>
                    </table>
                    And of course same goes for all the subsquent menu items.

                    SO then, if you change the main index.php (template) you have updated the whole site b/c there was only 1 template to update.

                    I hope this helps, and I hope there isn't to much wrong with the samples I have given you good luck.
                    Last edited by Conscience; Sat 23 Mar '02, 8:35pm.
                    Cons

                    Comment


                    • #11
                      Thank you so much as that explained a lot of things to me. I appreciate it very much.

                      Ok, now that it loads the contents from that one page, is there anyway that you can use that page it loads to "override" some of the layout of the template? This is so that when they click on a news article they could make the title of the page turn into <title>News Title</title> or make a banner going across that says "news page" or anything like that.

                      Its a bit hard to explain, but I will try to explain a bit in more detail:

                      Say you have a page that only has those links to the other PHP pages and nothing else, can you make it that when you click on one of those links, even though it is following the templete, it would actually change to a new page and/or add an object on the page such as an image at the top saying "news", but not inside of the location where the news article was "posted". Can you do that?

                      Oh, and another question:

                      1. Do the letters PHP represent anything other than simply "PHP"?

                      Again, thank you as that was very helpful and I will try that out later.

                      Comment


                      • #12
                        to make all the pages look the same, just make one document with a php extention and include other php extention documents in it.

                        the documents themselves don't even have to be written with php, they only need to have a .php extension.

                        simple layout=
                        <html>
                        <body>
                        <table width="100%" cellpadding=0 cellspacing=0 border=0>
                        <td width="100" valign="top" >
                        <?php include "left.php";?>
                        </td>
                        <td width="*%" valign="top" >
                        <?php include "center.php";?>
                        </td>
                        <td width="100" valign="top">
                        <?php include "right.php";?>
                        </td>
                        </table>
                        </body>
                        </html>
                        name that file index.php

                        then type in the contents of each <td> in seperate documents named:

                        left.php
                        center.php
                        right.php
                        Last edited by Max_Radius; Sat 23 Mar '02, 5:40pm.

                        Comment


                        • #13
                          u can do that if you want I wouldn't recommend it as it simply makes things harder to deal with.

                          about your title question...you can apply the same idea as the page includes.

                          so if ?page=grass

                          Code:
                          <title>
                          
                          <?
                          
                          if ($page == "grass) echo "Grass Page :)";
                          
                          ?>
                          
                          </title>
                          look up 'if' on php.net as well as 'switch'.
                          Cons

                          Comment


                          • #14
                            if you want to include a .php file into a sub directory page on your server, simply type


                            <td width="100" valign="top" >
                            <?php include "../left.php";?>
                            </td>

                            it works like html.

                            this way, I can use php to handle all sections of the page seperately, and it can be reused in other folders.

                            I use .css to handle the rest of the page format.

                            Easy as pie.

                            Comment


                            • #15
                              like I said millions of ways of doing it
                              Cons

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...
                              X