DEVSENSE / Phalanger

PHP 5.4 compiler for .NET/Mono frameworks. Predecessor to the opensource PeachPie project (www.peachpie.io).
http://v4.php-compiler.net/
Apache License 2.0
382 stars 94 forks source link

Find Current Page URL #65

Open sandeepsri opened 8 years ago

sandeepsri commented 8 years ago

How to find current page URL $pageURL = $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; getting error "Notice: Undefined offset"

System\Web\HttpContext::$Current->Request->Url->AbsoluteUri; getting error "Notice: An empty variable used as an object"

lucyllewy commented 8 years ago

WFM.

a file with the following content works as expected on the Visual Studio development server:

<?php
echo $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'];

output:

localhost:62931/test.php
sandeepsri commented 8 years ago

I am writing output Filter for Apache 2.4 web server, when I am running this with Apache then getting "Notice: Undefined offset (SERVER_NAME). Notice: Undefined offset (SERVER_PORT). Notice: Undefined offset (REQUEST_URI)."

lucyllewy commented 7 years ago

Can you run a script which outputs the $_SERVER variable via print_r() to try to figure-out the relevant keys. ASP.NET is not meant to operate as an Apache output filter by default, and Phalanger less-so. The $_SERVER variable is set from the environment variables set by Apache so if the hostname wasn't set by Apache then Phalanger cannot know what to set $_SERVER['SERVER_NAME'] to internally.

bfistein commented 5 years ago

@sandeepsri Phalanger's development is mostly discontinued in favor of PeachPie, the more modern compiler and runtime that also targets .NET Core. Please feel free to give that a try. @diddledan already knows about it :)