PDA

Visualizza la versione completa : Newbie_Perchè echo $_SERVER... non mostra


 
esseAemme
27-03-2012, 12:34
Buongiorno a tutti,

scrivo perchè sto cercando di capire e imparare.

Ho un server con apache e abilitato php.

Sto facendo un esercizio banale, ovvero ho creato un file che si chiama get_filename.php e al suo interno ho:



echo $_SERVER['SCRIPT_FILENAME'];


L'ho salvato sul server, e dal browser digito http://192.168.150.112/get_filename.php

Secondo il manuale dovrebbe restituirmi il path e il nome del file, mentre nel mio caso mi mostra il contenuto del file. Perchè?

Cosa sbaglio?

Grazie
Sam

esseAemme
27-03-2012, 13:02
ok...

okkei...

ok...

sgrunt.
:'
:| :| :|


Portate pazienza.... da qualche parte si deve pure iniziare... :|
Ciao
Sam

eiyen
27-03-2012, 13:10
quindi... risolto?

p.s. p.es.... verifica engine "php" e soprattutto... tag php...

esseAemme
27-03-2012, 13:32
Ciao Eiyen,

in realtà no. Avevo provato a portare fuori la funzione per capire cosa sbagliavo. Ma dove richiamo la funzione non funziona nulla.

Ecco qui, nel file index.php ho:


<div id="nav">
<?php
$menu=file_get_contents("inc/main_nav.php");
echo $menu;
?>
</div>


Nel file inc/main_nav.php invece:


<?php $currentPage = basename($_SERVER['SCRIPT_FILENAME']); ?>
<div id="main_nav">
<ul class="topnav">
<li id="main_nav_index">>Home (index.php)
<li id="main_nav_azienda" class="sub" >>Azienda (azienda.php)
[/list]
</div>



Solo che quando vedo la pagina index.php, sul browser i link vengono stampati così:
>Home
>Azienda

e nella sorgente pagina vedo tutto il codice php non interpretato...

Io scrivo come utente non root, forse non ho i permessi adeguati?

... Grazie per ogni suggerimento

Sam

eiyen
27-03-2012, 13:45
comincia con un singolo file "phpinfo.php" che contiene solo:



<?php phpinfo(); ?>


e chiamalo dal browser (verosimilmente: http://localhost/phpinfo.php)... che succede così?]

esseAemme
27-03-2012, 13:55
Ciao Eyen,
così mi fornisce moltissime informazioni (ti faccio un copia incolla):


PHP Version 5.2.6

System Linux weblab 2.6.32.12-0.7-pae #1 SMP 2010-05-20 11:14:20 +0200 i686
Build Date Feb 12 2010 15:16:47
Configure Command '../configure' '--prefix=/usr' '--datadir=/usr/share/php5' '--mandir=/usr/share/man' '--bindir=/usr/bin' '--with-libdir=lib' '--includedir=/usr/include' '--sysconfdir=/etc/php5/apache2' '--with-config-file-path=/etc/php5/apache2' '--with-config-file-scan-dir=/etc/php5/conf.d' '--enable-libxml' '--enable-session' '--with-mm' '--with-pcre-regex=/usr' '--enable-xml' '--enable-simplexml' '--enable-spl' '--enable-filter' '--disable-debug' '--enable-inline-optimization' '--disable-rpath' '--disable-static' '--enable-shared' '--program-suffix=5' '--with-pic' '--with-gnu-ld' '--with-system-tzdata=/usr/share/zoneinfo' '--with-apxs2=/usr/sbin/apxs2' '--disable-all' '--disable-cli'
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php5/apache2
Loaded Configuration File /etc/php5/apache2/php.ini
Scan this dir for additional .ini files /etc/php5/conf.d
additional .ini files parsed /etc/php5/conf.d/ctype.ini, /etc/php5/conf.d/dom.ini, /etc/php5/conf.d/hash.ini, /etc/php5/conf.d/iconv.ini, /etc/php5/conf.d/json.ini, /etc/php5/conf.d/tokenizer.ini, /etc/php5/conf.d/xmlreader.ini, /etc/php5/conf.d/xmlwriter.ini
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety disabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp
Registered Stream Socket Transports tcp, udp, unix, udg
Registered Stream Filters string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed

Suhosin logo This server is protected with the Suhosin Patch 0.9.6.2
Copyright (c) 2006 Hardened-PHP Project

Zend logo This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

PHP Credits
Configuration
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference Off Off
allow_url_fopen On On
allow_url_include Off Off
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors Off Off
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl Off Off
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 6143 6143
expose_php On On
extension_dir C:\php\ext C:\php\ext
file_uploads On On
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors Off Off
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .: .:
log_errors On On
log_errors_max_len 1024 1024
magic_quotes_gpc Off Off
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
mail.force_extra_parameters no value no value
max_execution_time 30 30
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 60 60
memory_limit 128M 128M
open_basedir no value no value
output_buffering 4096 4096
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv Off Off
register_globals Off Off
register_long_arrays Off Off
report_memleaks On On
report_zend_debug On On
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Off Off
safe_mode_include_dir no value no value
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail -t -i /usr/sbin/sendmail -t -i
serialize_precision 17 17
short_open_tag Off Off
SMTP 192.168.180.17 192.168.180.17
smtp_port 25 25
sql.safe_mode Off Off
suhosin.log.phpscript 0 0
suhosin.log.phpscript.is_safe Off Off
suhosin.log.phpscript.name no value no value
suhosin.log.sapi no value no value
suhosin.log.script no value no value
suhosin.log.script.name no value no value
suhosin.log.syslog no value no value
suhosin.log.syslog.facility no value no value
suhosin.log.syslog.priority no value no value
suhosin.log.use-x-forwarded-for Off Off
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 2M 2M
upload_tmp_dir no value no value
user_dir no value no value
variables_order GPCS GPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
y2k_compliance On On
zend.ze1_compatibility_mode Off Off

apache2handler
Apache Version Apache
Apache API Version 20051115
Server Administrator support@advnet.it
Hostname:Port www1.advnet.it:0
User/Group wwwrun(30)/8
Max Requests Per Child: 10000 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 300 - Keep-Alive: 15
Virtual Server Yes
Server Root /srv/www
Loaded Modules core prefork http_core mod_so mod_authz_host mod_actions mod_alias mod_auth_basic mod_authz_groupfile mod_authn_file mod_authz_user mod_autoindex mod_cgi mod_dir mod_include mod_log_config mod_mime mod_negotiation mod_setenvif mod_status mod_userdir mod_asis mod_imagemap mod_php5 mod_authz_default mod_sitemap

Directive Local Value Master Value
engine 1 1
last_modified 0 0
xbithack 0 0

Apache Environment
Variable Value
HTTP_HOST 192.168.150.112
HTTP_USER_AGENT Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0
HTTP_ACCEPT text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_ACCEPT_LANGUAGE it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_CONNECTION keep-alive
PATH /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin
SERVER_SIGNATURE no value
SERVER_SOFTWARE Apache
SERVER_NAME 192.168.150.112
SERVER_ADDR 192.168.150.112
SERVER_PORT 80
REMOTE_ADDR 192.168.150.165
DOCUMENT_ROOT /srv/www/advnet
SERVER_ADMIN support@advnet.it
SCRIPT_FILENAME /srv/www/advnet/phpinfo.php
REMOTE_PORT 54071
GATEWAY_INTERFACE CGI/1.1
SERVER_PROTOCOL HTTP/1.1
REQUEST_METHOD GET
QUERY_STRING no value
REQUEST_URI /phpinfo.php
SCRIPT_NAME /phpinfo.php

HTTP Headers Information
HTTP Request Headers
HTTP Request GET /phpinfo.php HTTP/1.1
Host 192.168.150.112
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding gzip, deflate
Connection keep-alive
HTTP Response Headers
X-Powered-By PHP/5.2.6
Keep-Alive timeout=15, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html


Directive Local Value Master Value
filter.default unsafe_raw unsafe_raw
filter.default_flags no value no value

libxml
libXML support active
libXML Version 2.7.1
libXML streams enabled

pcre
PCRE (Perl Compatible Regular Expressions) Support enabled
PCRE Library Version 7.8 2008-09-05

Directive Local Value Master Value
pcre.backtrack_limit 100000 100000
pcre.recursion_limit 100000 100000

Reflection
Reflection enabled
Version $Id: php_reflection.c,v 1.164.2.33.2.50 2008/03/13 15:56:21 iliaa Exp $

session
Session Support enabled
Registered save handlers files user mm
Registered serializer handlers php php_binary

Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn Off Off
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path no value no value
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0

SimpleXML
Simplexml support enabled
Revision $Revision: 1.151.2.22.2.39 $
Schema support enabled

SPL
SPL support enabled
Interfaces Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver,

standard
Regex Library Bundled library enabled
Dynamic Library Support enabled
Path to sendmail /usr/sbin/sendmail -t -i

Directive Local Value Master Value
assert.active 1 1
assert.bail 0 0
assert.callback no value no value
assert.quiet_eval 0 0
assert.warning 1 1
auto_detect_line_endings 0 0
default_socket_timeout 60 60
safe_mode_allowed_env_vars PHP_ PHP_
safe_mode_protected_env_vars LD_LIBRARY_PATH LD_LIBRARY_PATH
url_rewriter.tags a=href,area=href,frame=src,input=src,form=fakeentr y a=href,area=href,frame=src,input=src,form=fakeentr y
user_agent no value no value

xml
XML Support active
XML Namespace Support active
libxml2 Version 2.7.1

Additional Modules
Module Name

Environment
Variable Value
LESSKEY /etc/lesskey.bin
NNTPSERVER news
INFODIR /usr/local/info:/usr/share/info:/usr/info
MANPATH /usr/share/man:/usr/local/man
HOSTNAME weblab
XKEYSYMDB /usr/share/X11/XKeysymDB
HOST weblab
TERM xterm
SHELL /bin/bash
PROFILEREAD true
HISTSIZE 1000
SSH_CLIENT 192.168.150.166 55621 22
MORE -sl
get_module_list_done true
SSH_TTY /dev/pts/0
LC_ALL POSIX
USER root
LS_COLORS
XNLSPATH /usr/share/X11/nls
ENV /etc/bash.bashrc
HOSTTYPE i386
FROM_HEADER no value
PAGER less
COLUMNS 237
CSHEDIT emacs
XDG_CONFIG_DIRS /etc/xdg
get_includes_done true
MINICOM -c on
MAIL /var/mail/root
PATH /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin
CPU i686
INPUTRC /etc/inputrc
PWD /etc/apache2/vhosts.d
LANG POSIX
PYTHONSTARTUP /etc/pythonstart
LINES 64
QT_SYSTEM_DIR /usr/share/desktop-data
SHLVL 3
HOME /var/lib/apache2
LESS_ADVANCED_PREPROCESSOR no
OSTYPE linux
LS_OPTIONS -A -N --color=tty -T 0
XCURSOR_THEME DMZ
WINDOWMANAGER /usr/bin/gnome
LESS -M -I
MACHTYPE i686-suse-linux
LOGNAME root
CVS_RSH ssh
XDG_DATA_DIRS /usr/share:/etc/opt/kde3/share:/opt/kde3/share
LC_CTYPE en_US.UTF-8
SSH_CONNECTION 192.168.150.166 55621 192.168.150.112 22
LESSOPEN lessopen.sh %s
INFOPATH /usr/local/info:/usr/share/info:/usr/info
LESSCLOSE lessclose.sh %s %s
G_BROKEN_FILENAMES 1
COLORTERM 1
_ /sbin/startproc
PREVLEVEL N
RUNLEVEL 3
DAEMON /usr/sbin/httpd2-prefork

PHP Variables
Variable Value
_SERVER["HTTP_HOST"] 192.168.150.112
_SERVER["HTTP_USER_AGENT"] Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0
_SERVER["HTTP_ACCEPT"] text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
_SERVER["HTTP_ACCEPT_LANGUAGE"] it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
_SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate
_SERVER["HTTP_CONNECTION"] keep-alive
_SERVER["PATH"] /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin
_SERVER["SERVER_SIGNATURE"] no value
_SERVER["SERVER_SOFTWARE"] Apache
_SERVER["SERVER_NAME"] 192.168.150.112
_SERVER["SERVER_ADDR"] 192.168.150.112
_SERVER["SERVER_PORT"] 80
_SERVER["REMOTE_ADDR"] 192.168.150.165
_SERVER["DOCUMENT_ROOT"] /srv/www/advnet
_SERVER["SERVER_ADMIN"] support@advnet.it
_SERVER["SCRIPT_FILENAME"] /srv/www/advnet/phpinfo.php
_SERVER["REMOTE_PORT"] 54071
_SERVER["GATEWAY_INTERFACE"] CGI/1.1
_SERVER["SERVER_PROTOCOL"] HTTP/1.1
_SERVER["REQUEST_METHOD"] GET
_SERVER["QUERY_STRING"] no value
_SERVER["REQUEST_URI"] /phpinfo.php
_SERVER["SCRIPT_NAME"] /phpinfo.php
_SERVER["PHP_SELF"] /phpinfo.php
_SERVER["REQUEST_TIME"] 1332845486

eiyen
27-03-2012, 14:00
non serviva :) cmq riprova con i tuoi file, ma nel primo dovresti cambiare $menu=file_get_contents("inc/main_nav.php"); con include("inc/main_nav.php");

esseAemme
27-03-2012, 14:07
Eiyen: c'ai come ragione...

:) Grazie mille, devo ancora sistemare il codice php, perhcè

<li id="main_nav_index">Home (index.php)

devo staccare ...php" id ma per il resto funziona alla grande!!!

Grazie mille per il tuo tempo :D

Samantha :)

Loading