User Tag List

Results 1 to 4 of 4

Thread: [PHP Help] Include contents of one file to others

  1. #1
    Member
    • 's Gadgets
      • Motherboard:
      • Asus P5KPL-AM
      • CPU:
      • Dual Core E5400
      • RAM:
      • Transcend + Kingston = 4 GB DDR2
      • Hard Drive:
      • 250 GB Hitachi Deskstar T7K250 + Samsung F3 500 GB
      • Graphics Card:
      • Built-In
      • Display:
      • AOC F22 22"
      • Sound Card:
      • Realtek
      • Speakers/HPs:
      • Creative Live 4.1/Logitech G35
      • Keyboard:
      • A4Tech
      • Mouse:
      • Delux
      • Power Supply:
      • Thermaltake Lite Power 400 Watts
      • Optical Drive:
      • BUSTED !
      • USB Devices:
      • Transcend 16GB
      • UPS:
      • DigitalX 650VA
      • Operating System:
      • Windows 8 Pro x64
      • Comment:
      • Gave up on PC......at least for now
      • ISP:
      • IS PROS
      • Download Speed:
      • Average: 24 Kbps
      • Upload Speed:
      • Average: 24 Kbps
      • Console:
      • 16
    йЦммєя³¹'s Avatar
    Join Date
    Apr 2009
    Location
    +23° 45' 10.07", +90° 23' 5.39"
    Posts
    1,932

    Question [PHP Help] Include contents of one file to others

    for example i have multiple paras of static content in a php file
    now i'd like to include those paras into their respective pages
    i can do whole contents of one file but not selective contents of 1 file
    Code:
    <a href="index.php?page=contact">Contact Us</a>
    Code:
    <?php 
    
    
    if(isset($_REQUEST['page']) && !empty($_REQUEST['page']))
    {
        $page = $_REQUEST['page'];
    }
    
    
    else
    {
        $page = "home";
    }
    
    
    include($page.'.php');
    
    
    ?>

    i hope i was able to explain the problem
    any suggestion will be much appreciated
    01000010011000010111101001101001011011100110011101100001001000010010000100100001 001000000011101001010000

  2. #2
    Global Moderator
    • Codex's Gadgets
      • Motherboard:
      • Asus P8Z77-V
      • CPU:
      • Intel Core i7 3770k
      • RAM:
      • G.Skill Sniper 2x8G (9-9-9-24 Kits)
      • Hard Drive:
      • Samsung 850 PRO 256G SSD, Geil 512G SSD, HDDs: 2TBx1, 1TBx1, 500Gx1, 165Gx1
      • Graphics Card:
      • Sapphire R9 280x (Dual-x edition)
      • Display:
      • Triple monitors: Samsung S24300B + Dell E2210 x2
      • Sound Card:
      • CEntrance DACport Slim
      • Speakers/HPs:
      • Sennheiser HD598 / FLC 8s
      • Keyboard:
      • Thermaltek Challenger Pro
      • Mouse:
      • Logitech MX Master w/ Razer Goliathus Mid.
      • Controller:
      • Don't have one
      • Power Supply:
      • Inwin 750 watts w/ 80+ Bronze Certification
      • Optical Drive:
      • Asus DRW24B3ST
      • USB Devices:
      • 2TB Seagate External USB 3.0 drive
      • UPS:
      • Mercury 1.2KVA
      • Operating System:
      • Genuine Windows 10 Pro
      • Benchmark Scores:
      • Over nine thousand!
      • Comment:
      • ISP:
      • AntBD + AmberIT Dual Homed
      • Download Speed:
      • ~ 1200 KB/s
      • Upload Speed:
      • ~ 1200 KB/s

    Join Date
    Nov 2008
    Location
    Under your bed.
    Posts
    7,983

    Default

    Ideally those parts would be further broken down into their own files not only for organization's sake but also so you're not including a bunch of code that will not be used.
    But if you want to have those pieces all in one page you can put each piece into a function and then call the appropriate function when needed.

    For example:

    Code:
    
    <?php
    
    function printHeader()
    {
    ?>
        <html>
            <head>
                <title>Test Page</title>
            </head>
            <body>
    <?
    }
    
    function printFooter()
    {
    ?>
            </body>
        </html>
    <?  
    }
    
    ?>
    There's no direct support for only loading parts of a file.

  3. #3
    Member
    • 's Gadgets
      • Motherboard:
      • Asus P5KPL-AM
      • CPU:
      • Dual Core E5400
      • RAM:
      • Transcend + Kingston = 4 GB DDR2
      • Hard Drive:
      • 250 GB Hitachi Deskstar T7K250 + Samsung F3 500 GB
      • Graphics Card:
      • Built-In
      • Display:
      • AOC F22 22&quot;
      • Sound Card:
      • Realtek
      • Speakers/HPs:
      • Creative Live 4.1/Logitech G35
      • Keyboard:
      • A4Tech
      • Mouse:
      • Delux
      • Power Supply:
      • Thermaltake Lite Power 400 Watts
      • Optical Drive:
      • BUSTED !
      • USB Devices:
      • Transcend 16GB
      • UPS:
      • DigitalX 650VA
      • Operating System:
      • Windows 8 Pro x64
      • Comment:
      • Gave up on PC......at least for now
      • ISP:
      • IS PROS
      • Download Speed:
      • Average: 24 Kbps
      • Upload Speed:
      • Average: 24 Kbps
      • Console:
      • 16
    йЦммєя³¹'s Avatar
    Join Date
    Apr 2009
    Location
    +23° 45' 10.07", +90° 23' 5.39"
    Posts
    1,932

    Default

    thanx man
    very stupid of me not to think about it
    have been busy with a different paradigm (.NET)
    so, forgot all the PHP stuff
    can u discuss the matter that when i call a method/function in .NET it gets executed
    but like the function u wrote in PHP is 'pasted' rather than being executed
    can the same 'pasting' thing be done in .NET and is there any formal term for this ?
    01000010011000010111101001101001011011100110011101100001001000010010000100100001 001000000011101001010000

  4. #4
    Global Moderator
    • Codex's Gadgets
      • Motherboard:
      • Asus P8Z77-V
      • CPU:
      • Intel Core i7 3770k
      • RAM:
      • G.Skill Sniper 2x8G (9-9-9-24 Kits)
      • Hard Drive:
      • Samsung 850 PRO 256G SSD, Geil 512G SSD, HDDs: 2TBx1, 1TBx1, 500Gx1, 165Gx1
      • Graphics Card:
      • Sapphire R9 280x (Dual-x edition)
      • Display:
      • Triple monitors: Samsung S24300B + Dell E2210 x2
      • Sound Card:
      • CEntrance DACport Slim
      • Speakers/HPs:
      • Sennheiser HD598 / FLC 8s
      • Keyboard:
      • Thermaltek Challenger Pro
      • Mouse:
      • Logitech MX Master w/ Razer Goliathus Mid.
      • Controller:
      • Don't have one
      • Power Supply:
      • Inwin 750 watts w/ 80+ Bronze Certification
      • Optical Drive:
      • Asus DRW24B3ST
      • USB Devices:
      • 2TB Seagate External USB 3.0 drive
      • UPS:
      • Mercury 1.2KVA
      • Operating System:
      • Genuine Windows 10 Pro
      • Benchmark Scores:
      • Over nine thousand!
      • Comment:
      • ISP:
      • AntBD + AmberIT Dual Homed
      • Download Speed:
      • ~ 1200 KB/s
      • Upload Speed:
      • ~ 1200 KB/s

    Join Date
    Nov 2008
    Location
    Under your bed.
    Posts
    7,983

    Default

    I have no idea about .net, so really can't help you there, lol.

Similar Threads

  1. Replies: 33
    Last Post: February 8th, 2012, 22:59
  2. Replies: 0
    Last Post: December 9th, 2011, 14:17
  3. Help Needed Convert bik File To Any video File without RAD
    By Albert SX65 in forum Technical Support
    Replies: 7
    Last Post: June 4th, 2010, 22:23
  4. Replies: 13
    Last Post: July 11th, 2009, 16:36
  5. [PHP] PHP Encoder
    By Saibal in forum Programming
    Replies: 3
    Last Post: June 15th, 2008, 01:23

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 0.17165 seconds with 14 queries.