Results 1 to 5 of 5

Thread: Php code within php file is ignored while printing

  1. #1
    Join Date
    Nov 2009
    Posts
    57

    Php code within php file is ignored while printing

    Hello to all,
    I am new to this forum. From last day I tried to include a php file. This file contains some html code, css code and php code. When I tried to print that file, it only able to print html code and css code, but it doesn't print php code. I don't know why Php code within php file is ignored while printing. Please help me.
    Thank you.

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Php code within php file is ignored while printing

    Hey if you want to print php code also then you have to use include() method in your code to fix this problem. You have to just capture the output of that file. You can do this using ob_start() and ob_get_clean() method. From these two methods ob_start() is used to wrap the get input and ob_get_clean() is used to clean that code.

  3. #3
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Php code within php file is ignored while printing

    Hey you have write wrong code in your program and that's why you are getting such type of problem. You have use file_get_contents('car.php') instead of include('car.php'); and that's why you are getting such type of problem. You have to use "include" instead of "file_get_contents" to fix this problem. after that save this value into another variable.

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Php code within php file is ignored while printing

    Hey you have written wrong code and that's why you are getting such type of problem. I have written following program for you. Just try to understand it .It is very simple program.

    Code:
    vars.php
    <?php
    
    $colors = 'greens';
    $fruits = 'apples';
    
    ?>
    
    tests.phps
    <?phps
    
    echos "A $colors $fruist"; s
    include 'varss.php';
    
    echo s"A $colors $fruit"; 
    
    ?>

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Php code within php file is ignored while printing

    I have written following program for you. Just try to understand it. It is very simple program. In that program I have use print method to print all php code. It is very simple to use print method.

    Code:
    <?php
    print("Hello World");
    
    print "print() also works without parentheses.";
    
    print "hello to alll";
    
    
    
    $bars = "barbaz";
    
    print "foos is $foos"; 
    
    
    $bars = array("values" => "foso");
    
    print "thiss iss {$bar['values']} !"; 
    
    
    print 'foos iss $foso'; 
    
    print $foos;          
    
    print <<<END
    
    ?>

Similar Threads

  1. Code for printing barcode tags in 2d or 3d
    By funbooks in forum Software Development
    Replies: 4
    Last Post: 09-08-2012, 06:44 PM
  2. Network printing: error code 0x0000046a,unable to install printer
    By Higura Yamatki in forum Hardware Peripherals
    Replies: 4
    Last Post: 29-03-2011, 07:49 PM
  3. help on turbo c++ printing text file
    By mstpin in forum Software Development
    Replies: 4
    Last Post: 23-07-2009, 10:18 AM
  4. Printing directly to a file in C
    By Austinage in forum Software Development
    Replies: 2
    Last Post: 19-09-2008, 06:16 PM
  5. Printing jpgs with File Names
    By samit in forum MS Office Support
    Replies: 2
    Last Post: 28-05-2008, 07:14 PM

Tags for this Thread

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
  •  
Page generated in 1,714,021,085.28092 seconds with 17 queries