PHP 5.3.1 PHAR outputting readable chars

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jatin
Forum Newbie
Posts: 2
Joined: Wed Apr 21, 2010 11:28 pm

PHP 5.3.1 PHAR outputting readable chars

Post by jatin »

Hello,
I am trying to make a simple PHAR archive work:
here's what I am trying to do : Create a .phar file that simply outputs "Hello world" nothing fancy.
using :
Ubuntu9.10
PHP 5.3.1 (using the xampp stack)

here's the code for index.php

Code: Select all

<?php
echo "Hello World";
?>
here the code I use to create the phar (create.php)

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', 'on');
$phar = new Phar('myphar.phar'); // I have even tried putting this as myphar.phar.php 
$phar->addFile("index.php");
?>
I execute it using
-> php5.3.1 create.php

Now above code does create a myphar.phar which is great but when I try to access this file using the command line
-> php5.3.1 myphar.phar

or even renamed and executer
-> php5.3.1 myphar.phar.php

it displays "��???" <- some rubbish with boxes and ??? if you cannot see it, same case when using the browser too. renaming to it myphar.phar.php also has no effect. I also tried setting the stub file and then using the above code does not work. I also added the httpd.conf setting to parse .phar as .php and re-tried, same results.

Anyone has an idea what wrong am I doing ? or is theres a bug in the code. :banghead:

Note : I have also tried removeing the error reporting and display errors code, no success
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP 5.3.1 PHAR outputting readable chars

Post by requinix »

PHP can't run PHARs directly unless they have a stub.
jatin
Forum Newbie
Posts: 2
Joined: Wed Apr 21, 2010 11:28 pm

Re: PHP 5.3.1 PHAR outputting readable chars

Post by jatin »

tasairis, thx for reply that might be the case but I have even tried it with a stub file and it still does not work.
Its working on windows correctly :(
Post Reply