Php Script displaying source on browser instead of executing it
Collapse
X
-
chmond problem.
And file format reading when saving a file.
Save the file as TEXT not assr
Leave a comment:
-
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:
-
add this in your .htaccess
HTML Code:<FilesMatch "\.ph(p[2-6]?|tml)$"> SetHandler application/x-httpd-php </FilesMatch>
Leave a comment:
-
I'm not arguing, and I'm not saying which PHP tag is better,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?
but the simple fact is that
is exact same asPHP Code:<? ...if you dont understand that,PHP Code:<?php ...
then that is your problem and your lack of knowledge.
Leave a comment:
-
@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:
-
like i said...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.
is equal toPHP Code:<? ...
and alsoPHP Code:<?php ...
is equal toPHP Code:<?= ...
PHP Code:<? echo ...
source: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.
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:
-
I honestly have always have that disabled from our local servers to hostgator.Originally posted by GumSlone View Postdont 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" ?>'; ?>
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:
-
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:
-
@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:
-
Originally posted by chelios View PostBrowser 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
Corect way to do itPHP Code:<?
print "Bad formating";
?>
PHP Code:<?php
print "Corect formating";
?>I wonder how you two PRO's manage to run your sites...Originally posted by phoenix90 View PostThis 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 <?
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
your way to solution is in arnage's reply...Originally posted by wapdxoo View PostThanks your your replies.. But, i've done evrytin needed to be done.. Pls see http://nxsite.t15.org/forum
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:
-
Its an result of using PHP: highlight_string - Manual by looking in the source.Originally posted by wapdxoo View PostThanks your your replies.. But, i've done evrytin needed to be done.. Pls see http://nxsite.t15.org/forum
Leave a comment:
-
Check this php files for errors ..Originally posted by wapdxoo View PostThanks your your replies.. But, i've done evrytin needed to be done.. Pls see http://nxsite.t15.org/forum
Reason why to check engine.php is that if there is no errrors ,PHP Code:require("../inc/engine.php");
but error is in
anything should be in order until main() function is calledPHP Code:// Main
main();
Leave a comment:
-
show us ur script or check your script againOriginally posted by wapdxoo View Posti 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?
Leave a comment:
-
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 checkLast edited by phoenix90; 12.06.13, 09:22.
Leave a comment:
Leave a comment: