PHP show_source not working on my server (Altervista) - php

I am trying to display the PHP source of a file inside a page. I am using show_source function in this way:
<?php
$nomefile = $_REQUEST['nome'];
show_source($nomefile);
?>
When I try this code on my local PC (using USBWebserver v8.6), it works smoothly, displaying the PHP code of the page. But when I try it on my remote webserver (Altervista), I only get an empty page.
I even try to substitute variable $nomefile with name "visite.php", which is the name of a file residing in the same folder, but still I get no result? I try with echo show_source(...), but no result again.
Is there an error in my code? Or maybe show_source is not compatible with all version of PHP? Is there any easy alternative?
Thanks a lot
Giancarlo Perlo - Italy

Related

PHP getting copy function to work

My copy code doesnt work for some reason. Tried several things.
this is the code that I am trying to use
$fb_foto_url = $userData['picture']['data']['url'];
$plaats = '/assets/images/profielfotos/fiel.jpg';
copy($fb_foto_url, $plaats);
The $userData['picture']['data']['url']is getting filled with this for example: https://lookaside.facebook.com/platform/profilepic/?asid=113831052838678&height=200&width=200&ext=1527931138&hash=AeSlklMNX6l4Uanh
I need that to get stored in on the server. But it isn't working for some reason. I am doing something wrong but can't figure out what.
If someone can help me with this code, would be nice.
Try this:
file_put_contents($plaats,file_get_contents($fb_foto_url));
PHPs copy function expects path's, not URL's.
A (server-) path is a directory name on the machine the PHP code is executed on.
An URL is a virtual name that may or may not point to such a physical path or is resolved dynamically.
Example:
The server path to a websites images might be /var/www/example.org/assets/images/, while the URL is http://example.org/assets/images/.
http://php.net/manual/en/function.copy.php

Basic php can't run in my browser. It includes the "$" , ";" and etc. in html

I'm learning PHP coding and I can't solve this problemIt's includes the variables and the endlines.
I'm new to the language.
There is no other issue, fix your xampp problem, put your project in xampp > htdocs folder, save your file with .php extension and go to browser write http://localhost/project/page.php
Update: You are calling POST values, meaning a form (similar to a login form) has to send the values of tireqty, oilqty, and sparkqty to that page.
So you generally want to start a .php file with <?php at the very top. I would recommend doing a simple example like this:
<?php
echo '<p>1</p>';
?>
<p>2</p>
Or, change your file to reflect .html instead. You should be able to still have the php run properly there like this:
<p>1</p>
<?php
echo '<p>2</p>';
?>
If this doesn't work, please update your question to provide:
Operating System
What program you're using
What browser you're using
What version of PHP you're using
Any other information about your system
php html server

iOS Swift / HTML-Code and PHP-Code in 'Strings'

I tried the following coding for a 'UIWebView:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1></body></html>"
This HTML code works fine and "UIWebView" shows this code. But if I try to insert a PHP code within the HTML code like this:
let kapitel3 = "<html><head><title>Chapter 1</title></head><body><h1>This is a title!</h1><?php print \"Hello world!\";?></body></html>"
Then the PHP code won't be showed. Why doesn't 'UIWebView' translate this PHP code <?php print \"Hello world!\";?>?
Is it not possible to integrate PHP code in a String like above?
Thanks for any hints!
UIWebView is only a simple web-browser...
You can't use php like that if you don't have a local webserver with a php interpreter installed!
You could load a php page from a remote url but your phone must have an active internet connection...
Possible local solution:
You can't use php locally, but in a UIWebView you can still use javascript!
I don't know what you are trying to do...but if you need your app to work offline (with local files) using php is the wrong approach.

content of variable php hide when pass to 5.2-.5.3 to 5.4+ php version

i have a web site build some years ago, this site for more time is hosted on server with php 5.2, now i have decided to upgrade the server , the configuaration of new server is
-Centos
-php 5.4.16
-apache 2.4
when move the site on new server , every work fine but some output of variable not work , in this variable is present some code and some special caracther example ("?:.).
in new site the output of this variable is not printed , th code is this :
<?php
include_once "/opt/bitnami/apache2/htdocs/inc/settings/list.php";
echo $_form['list']['two'];
?>
in this page (list.php) is present this code:
http://pastebin.com/egVE9ff0
i tried to insert in this variable a text example and work fine , i tried number and work fine, i tried the DOT and work fine, so the problem is conflict between 2+ element in in this code.
in a server with php 5.2-5.3 work fine, in a server with 5.4.16-5.5 not work
the problem is , not show the output. the source code is full white.
Having a look at your code:
<?
$_form['list']['two'] = "
ciao INFORMATIVA IN BASE ALL'ART. 13 D. LGS. 196/2003
...
The problem is that newer version of PHP don't (by default) support <? a.k.a short_open_tag.
The easiest way to fix it is to change <? to <?php:
<?php
$_form['list']['two'] = "
ciao INFORMATIVA IN BASE ALL'ART. 13 D. LGS. 196/2003
...

Accessing Object in PHP

I've some strange issues with some php code.
if ($user->userType=='admin'){
If I use the above command, the php engine just stop interpreting and display the code in plain text on my browser. On the other hand if I use the below method it works:
if ($user['userType']=='admin'){
Again here also:
$_SESSION['currentUser']->id
If I use the above code it just displays the rest of code as plain text:
id); // fail user }else{ $authentication="failed"; $noAuthPresentation="loginForm"; }
Why this is happening? It's a big project and I don't want to change every line where there is an occurrence of ->.
Do I need to change some setting somewhere? I'm using WAMP server with php 5.5.12.
Any help ? Thanks!
You're mixing up types, user is an array, and not an object. Something in your php config is doing something strange to your error display it seems. Right click on the page that has the errors, and view source if possible.
Does login.php contain html and php code by chance?

Categories