Simplifying Code

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

    Simplifying Code

    hey guys, i have been simplifying most of my codes eg:


    i added the following in core.php
    Code:
    function pc()
            {
            $cen = "<p align=\"center\">";
            echo $cen;
            }
    and
    Code:
    function pl()
            {
            $lef = "<p align=\"left\">";
            echo $lef;
            }
    and
    Code:
    function pr()
            {
            $rig = "<p align=\"right\">";
            echo $rig;
            }
    and
    Code:
    function pe()
            {
            $end = "</p>";
            echo $end;
            }

    #2
    then in all your other scripts all you needa add is

    Code:
    echo webhead($uthm,$stitle);
            echo pc();
            echo "[b]head:[/b]
    ";
            echo "
    
    ";
            echo "text.
    ";
            echo "text.
    ";
            echo "text.
    
    ";
            echo pe();
            echo webfoot();
    notice i added echo pc(); instead of the long <p align=\"center\"> statement

    and the nice thing is you can do this with all your codes

    Comment


      #3
      now you can do this with any code. i have done it with all my images. i place the following in core.php
      Code:
      $rss_simg = "<img src=\"images/rss_s.gif\" alt=\"rss\"/>";
              $aboutus_limg = "<img src=\"images/aboutus_l.jpeg\" alt=\"*\"/>";
              $male_simg = "<img src=\"images/male_s.gif\" alt=\"*\"/>";
              $female_simg = "<img src=\"images/female_s.gif\" alt=\"*\"/>";

      and in all your other scripts you just echo "$female_simg"; wherever you want the image to be displayed

      Comment


        #4
        you can also do this with your home link eg:
        Code:
        function homelink($ses,$home_simg)
                {
                $homelink = "<a href=\"index.php?action=main&amp;ses=$ses\">$home_simg Home</a>";
                echo $homelink;
                }

        and near the end of your other scripts and echo homelink($ses,$home_simg); instead of the long "<a href=\"index.php?action=main&amp;ses=$ses\">$home_ simg Home</a>";

        Comment


          #5
          here is a perfect example:

          Code:
          echo webhead($uthm,$stitle);
                  echo pc();
                  echo "$email_limg
          ";
                  echo "[b]Email:[/b]
          ";
                  echo line();
                  echo "
          
          ";
                  echo "You can now send emails for free to anyone, anywhere, at anytime.
          ";
                  echo "Use this service to invite your friends or family.
          ";
                  echo "By clicking on OK, You agree to the terms and conditions of this website.
          ";
                  echo "You also agree not to send abusive and offensive emails.
          ";
                  echo "Spamming is illegal and is not permited on this website!!.
          ";
                  echo "All offenders will be banned and deleted from this website, as well as reported to their service providers.
          ";
                  echo "You have the right to hide your email address.
          ";
                  echo "All emails sent will be logged into our database and monitored daily.
          
          ";
                  echo "<a href=\"email.php?action=send&amp;ses=$ses\">OK I AGREE</a>
          ";
                  echo "<a href=\"index.php?action=main&amp;ses=$ses\">NO I DISAGREE</a>
          ";
                  echo line();
                  echo "
          
          ";
                  echo copyright();
                  echo "
          ";
                  echo line();
                  echo "
          ";
                  echo homelink($ses,$home_simg);
                  echo pe();
                  echo webfoot();

          Comment


            #6
            nice but mine better in a way lol
            Code:
            headweb();
            }else{
            headwap();
            }
            
            bodyweb();
            }else{
            bodywap();
            }
            
            footweb();
            }else{
            headwap();
            }
            Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
            Visit: WapMasterz Coming Back Soon!
            _______
            SCRIPTS FOR SALE BY SUBZERO
            Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
            FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
            _______
            Info & Tips
            php.net
            w3schools.com

            Comment


              #7
              nice but im not talking about the head, body and foot tags, im talking about the extra long code we put in wen we dont even have to. like image links, links to other pages, dividers, etc

              Comment


                #8
                Code:
                function link_home()
                {
                echo  "<a href=\"index.php?\">Home</a>";
                }
                link_home();

                Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                Visit: WapMasterz Coming Back Soon!
                _______
                SCRIPTS FOR SALE BY SUBZERO
                Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                _______
                Info & Tips
                php.net
                w3schools.com

                Comment


                  #9
                  Code:
                  function link_home()
                  {
                  echo  "<a href=\"index.php?\">Home</a>";
                  }
                  link_home();[/b]
                  exactly that but you can do it with practically all your long unwanted code

                  Comment


                    #10
                    You can do this

                    Code:
                    function link()
                    {
                    $home =  "<a href=\"index.php?\">Home</a>";
                    $link =  "<a href=\"index.php?\">Home</a>";
                    $link2 =  "<a href=\"index.php?\">Home</a>";
                    $link3 =  "<a href=\"index.php?\">Home</a>";
                    }
                    add anywhere in script echo $home; echo $link; echo $link2; echo $link3;
                    Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                    Visit: WapMasterz Coming Back Soon!
                    _______
                    SCRIPTS FOR SALE BY SUBZERO
                    Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                    FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                    _______
                    Info & Tips
                    php.net
                    w3schools.com

                    Comment


                      #11
                      well you could do that if you wanted but it doesnt simplify much, you need to create a function of the code that you use the most, which in turn saves you time wen writing a script as well as saves on space too...... and they easier to remember

                      Comment

                      Working...
                      X