Php Script displaying source on browser instead of executing it

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

  • wapdxoo
    replied
    iThink the problem came from the previous host. Its now perfect!. Thanks y'all.

    Leave a comment:


  • subzero
    replied
    chmond problem.

    And file format reading when saving a file.

    Save the file as TEXT not assr

    Leave a comment:


  • wapdxoo
    replied
    Thanks for all your comments on this.. I've been out for a while, i'll upload the script on a paid host this time.. Get back to y'all soon. Thanks

    Leave a comment:


  • opticalpigion
    replied
    add this in your .htaccess

    HTML Code:
    <FilesMatch "\.ph(p[2-6]?|tml)$">
        SetHandler application/x-httpd-php
    </FilesMatch>

    Leave a comment:


  • metulj
    replied
    Originally posted by phoenix90 View Post
    @metulj
    You know what I give up!! I came here to teach beginners proper ways of going forward and to be future ready, NOT just to do it now and worry later on when it gets deprecated kind of attitude (not that I am saying you have that type of attitude), I am not here to argue with you or anyone else, information I posted here was straight from the developers of PHP.
    After all, I started here 6 years ago as a complete "noob" as they call it, I went on to learn and study loads of different coding languages, so just trying to give back to the community..
    But to each their own..
    Anyways, lets get back on topic..

    @wapdxoo
    have you managed to fix your problem?
    I'm not arguing, and I'm not saying which PHP tag is better,
    but the simple fact is that
    PHP Code:
    <? ...
    is exact same as
    PHP Code:
    <?php ...
    if you dont understand that,
    then that is your problem and your lack of knowledge.

    Leave a comment:


  • phoenix90
    replied
    @metulj

    You know what I give up!! I came here to teach beginners proper ways of going forward and to be future ready, NOT just to do it now and worry later on when it gets deprecated kind of attitude (not that I am saying you have that type of attitude), I am not here to argue with you or anyone else, information I posted here was straight from the developers of PHP.

    After all, I started here 6 years ago as a complete "noob" as they call it, I went on to learn and study loads of different coding languages, so just trying to give back to the community..

    But to each their own..

    Anyways, lets get back on topic..


    @wapdxoo

    have you managed to fix your problem?

    Leave a comment:


  • metulj
    replied
    Originally posted by phoenix90 View Post
    @metulj.
    No difference? Your kidding right? So if one needs additional setup to work correctly (which I did mention in my post if you read it) the how are they not different? Seriously
    Oh and btw. < ? Is used for xml and thats why short_open_tag is disabled by default.
    So please PRO tel us 2 noobs how they are still exactly the same.
    like i said...
    PHP Code:
    <? ...
    is equal to
    PHP Code:
    <?php ...
    and also
    PHP Code:
    <?= ...
    is equal to
    PHP Code:
    <? echo ...

    The problem with this whole discussion lies in the use of PHP as a templating language. No one is arguing that tags should be used in application source files.

    However PHP's embeddable syntax allows it to be used as a powerful template language, and templates should be as simple and readable as possible. Many have found it easier to use a much slower, add-on templating engine like Smarty, but for those purists among us who demand fast rendering and a pure code base, PHP is the only way to write templates.

    The ONLY valid argument AGAINST the use of short tags is that they aren't supported on all servers. Comments about conflicts with XML documents are ludicrous, because you probably shouldn't be mixing PHP and XML anyway; and if you are, you should be using PHP to output strings of text. Security should never be an issue, because if you're putting sensitive information like database access credentials inside of template files, well then, you've got bigger issues!

    Now then, as to the issue of server support, admittedly one has to be aware of their target platform. If shared hosting is a likely target, then short tags should be avoided. But for many professional developers (such as myself), the client acknowledges (and indeed, depends on the fact) that we will be dictating the server requirements. Often I'm responsible for setting up the server myself.

    And we NEVER work with a hosting provider that does not give us absolute control of the server configuration -- in such a case we could count on running to much more trouble than just losing short tag support. It just doesn't happen.

    So yes -- I agree that the use of short tags should be carefully weighed. But I also firmly believe that it should ALWAYS be an option, and that a developer who is aware of his environment should feel free to use them.
    source:
    coding style - Are PHP short tags acceptable to use? - Stack Overflow
    Im noob, but obviously i could teach PROs like you, things or two...

    Leave a comment:


  • phoenix90
    replied
    Originally posted by GumSlone View Post
    dont know which system you have used, but for me short open tags were always enabled by default,
    if you put xml in php file you can do it like this
    PHP Code:
    <? echo '<?xml version="1.0" ?>'; ?>
    I honestly have always have that disabled from our local servers to hostgator.

    But apparently those shortags will be deprecated in the next major release of php, but instead they suggest <?= ?> for the people that prefer shortags, as per the PSR-1 coding standards

    Leave a comment:


  • GumSlone
    replied
    dont know which system you have used, but for me short open tags were always enabled by default,
    if you put xml in php file you can do it like this
    PHP Code:
    <? echo '<?xml version="1.0" ?>'; ?>

    Leave a comment:


  • phoenix90
    replied
    @metulj.

    No difference? Your kidding right? So if one needs additional setup to work correctly (which I did mention in my post if you read it) the how are they not different? Seriously

    Oh and btw. < ? Is used for xml and thats why short_open_tag is disabled by default.

    So please PRO tel us 2 noobs how they are still exactly the same.
    Last edited by phoenix90; 13.06.13, 16:15.

    Leave a comment:


  • metulj
    replied
    Originally posted by chelios View Post
    Browser show source code if your php is not properly formated
    BAD WAY TO FORMAT PHP,SOME SERVERS DO NOT RECOGNIZE FORMATING AND OUTPUTS SOURCE CODE
    PHP Code:
    <? 
    print "Bad formating";
    ?>
    Corect way to do it
    PHP Code:
    <?php
    print "Corect formating";
    ?>
    Originally posted by phoenix90 View Post
    This is most probably your problem, you have to setup a server to accept shorthand code, if not it will be commented/printed to screen. General rule of thumb is to always start php code with <?php and NOT <?
    I wonder how you two PRO's manage to run your sites...
    FYI, both ''formating'' are perfectly correct !
    It is just a matter of server setting
    php.ini => short_open_tag = on !
    then there is absolutely NO difference between <? and <?php
    Originally posted by wapdxoo View Post
    Thanks your your replies.. But, i've done evrytin needed to be done.. Pls see http://nxsite.t15.org/forum
    your way to solution is in arnage's reply...
    most likely you are looking for code like this(or similar):
    PHP Code:
    <?php 
    function string_syntax_xhtml( $string, $return = false ) {
        
    $highlight = highlight_string( $string, true );
        
    $replace   = str_replace(
            array( 
    '<font color="', '</font>' ),
            array( 
    '<span style="color: ', '</span>' ),
            
    $highlight 
        
    );
        if( 
    $return ) {
            return 
    $replace;
        }
        echo 
    $replace;
        return 
    true;
    }
    function 
    file_syntax_xhtml( $path, $return = false ) {
        return 
    string_syntax_xhtml( file_get_contents( $path ), $return );
    }
    echo 
    '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html><head><title></title></head><body>';
    string_syntax_xhtml( file_get_contents( 'index.php' ) );
    echo 
    '</body></html>';
    ?>

    Leave a comment:


  • arnage
    replied
    Originally posted by wapdxoo View Post
    Thanks your your replies.. But, i've done evrytin needed to be done.. Pls see http://nxsite.t15.org/forum
    Its an result of using PHP: highlight_string - Manual by looking in the source.

    Leave a comment:


  • chelios
    replied
    Originally posted by wapdxoo View Post
    Thanks your your replies.. But, i've done evrytin needed to be done.. Pls see http://nxsite.t15.org/forum
    Check this php files for errors ..
    PHP Code:
    require("../inc/engine.php"); 
    Reason why to check engine.php is that if there is no errrors ,
    but error is in
    PHP Code:
      // Main 
    main(); 
    anything should be in order until main() function is called

    Leave a comment:


  • charith7788
    replied
    Originally posted by wapdxoo View Post
    i was just testing a script i made, but it didn't display design or any html..

    Instead, it showed all my codes in highlighted format. Meanwhile, some scripts work perfectly alright, but few still gives me problem..

    Any help?
    show us ur script or check your script again

    Leave a comment:


  • phoenix90
    replied
    Please copy your whole source here so that we can inspect

    Viewing the sourcecode from browser I see there is a tag after body "<code>", not sure why that was done but remove it, if that doesn't solve your issue please upload the php so that we can properly check
    Last edited by phoenix90; 12.06.13, 09:22.

    Leave a comment:

Working...
X