PHP Classes

Does not work - PTX throws an error

Recommend this page to a friend!

      PHP Snake Game  >  All threads  >  Does not work - PTX throws an error  >  (Un) Subscribe thread alerts  
Subject:Does not work - PTX throws an error
Summary:Missing PTX whatever that is...
Messages:4
Author:Ernie
Date:2015-03-18 17:42:58
 

  1. Does not work - PTX throws an error   Reply   Report abuse  
Picture of Ernie Ernie - 2015-03-18 17:42:59
What is this line for:
use \Ptx\Snake; ???

It throws errors on both my servers.
use \Ptx\Snake; on line 5 of index.php

Is Ptx a subfolder? A code call to a library that
you did not include?


  2. Re: Does not work - PTX throws an error   Reply   Report abuse  
Picture of Tomas Pavlatka Tomas Pavlatka - 2015-03-19 03:06:48 - In reply to message 1 from Ernie
Hi,

I'd say you are using server with old version of PHP. PHP < 5.3. Is this correct?

use \Ptx\Snake.php is just to use namespace which came with PHP 5.3 - have a look here http://php.net/manual/en/language.namespaces.rationale.php

You can remove it, do following.

// index.php
- remove require_once './bootstrap.php';
- remove use \Ptx\Snake
- add require_once './classes/Snake.php';

// classes/Snake.php
- remove namespace PTX;

Try it again and let me know.

  3. Re: Does not work - PTX throws an error   Reply   Report abuse  
Picture of Tomas Pavlatka Tomas Pavlatka - 2015-03-19 08:22:48 - In reply to message 1 from Ernie
Hi,

I apologize, but even this wouldn't help you as I use some things from PHP 5.4.

You can see the functionality here: http://ideone.com/B4Ep3l (this is a modified version for PHP 5.3)

Just copy the class and add it into your project. Let me now how it went.

Tomas

  4. Re: Does not work - PTX throws an error   Reply   Report abuse  
Picture of Ernie Ernie - 2015-03-19 11:08:49 - In reply to message 2 from Tomas Pavlatka
Thanks for the explanation.
My PHP server are both revision 5.2.17 !
Hince the issue.

I will attempt to update them and see what happens.
Or, perhaps I might take that out. I assume you have
it in there for a reason, so I will try to get updated first.

Thanks for explaining. I will post the results tomorrow...

 
For more information send a message to info at phpclasses dot org.