Php 5.2 namespace syntax error unexpected t_string

php 5.2 namespace syntax error unexpected t_string

Wordpress 3.5.2. PHP 5.2.17 (cli) (built: Mar 1 2012 16:36:14) Parse error: syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or. On this server PHP Version can be only anycodings_php 5.2.5, and seems like there is no full anycodings_php support of namespaces in it yet. Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING in /usr/local/www/apache22/data/wiki/includes/Namespace.php on line 46.

Php 5.2 namespace syntax error unexpected t_string - pity, that


After upgrading my PHP to 5.3.2, I received the following error when accessing MediaWiki (1.6.12):Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING in /usr/local/www/apache22/data/wiki/includes/Namespace.php on line 46

There are three solutions:

  1. Downgrade your PHP from 5.3 back to 5.2
  2. Upgrade your MediaWiki to a newer version.
  3. Fix the codes.

In my case, the first couple solutions do not work for me, and therefore I choose 3.

  1. Backup your wiki file first.
  2. Access your webserver and go to the MediaWiki/includes directory.
    For example:cd /usr/local/www/apache22/data/wiki/includes
  3. Edit Namespace.phpnano Namespace.php
  4. Go to line 46, change the following from: class Namespace {

    to:

    class MWNamespace {

    Save the file.

  5. Now, let’s create a script: nano wikifix.sh

    Copy and paste the following:

    for fl in *.php; do mv $fl $fl.old sed 's/Namespace::/MWNamespace::/g' $fl.old > $fl done

    Save the file.

  6. Change the file to executable by: chmod u+x wikifix.sh
  7. Search the keyword Namespace:: and replace it by MWNamespace::: ./wikifix.sh

    Warning: Don’t run the script twice!

  8. Delete the script. rm wikifix.sh

Try to access the MediaWiki again and the problem should be gone.

Enjoy Wiki.

–Derrick

Our sponsors:

Related

Posted in Computer Problems, Server Problems, Technology, Troubleshooting

Syntax Error Unexpected 3939 Expecting 3939

syntax error, unexpected ',', expecting ')'

Tags: ruby , syntax-error , ruby-1.9 Answers: 1

Topic on Project:Support desk

My in-house wiki for a game I'm developing was randomly blank, so I contacted my server admin, and got this response:

We are sorry for the inconvenience. However, the outdated MediaWiki installed on your account is not compatible with any new versions of PHP that is currently running on your server - those are PHP 5.3, 5.4 or 5.5. Please note that we have removed the outdated php 5.2 from our server. You'll need to upgrade Mediawiki to the latest version to resolve the issue. Please refer http://www.mediawiki.org/wiki/Manual:Upgrading

After following the instructions there, nothing seemed to work. I didn't even have a mw-config folder. Eventually I read that you have to upgrade from 1.14 to 1.15, and THEN upgrade to current. However, since the first botched attempt, updating to 1.15 now also fails.

I asked my admin to do some poking around himself, and he came to the same results I did:


I have also tried to update the MediaWiki manually and it ends up on blank page with the following error logs; [25-Jul-2014 20:05:42 America/New_York] PHP Parse error: syntax error, unexpected 'Namespace' (T_NAMESPACE), expecting identifier (T_STRING) in /home/bavnbzjp/wiki/includes/Namespace.php on line 52 [25-Jul-2014 20:06:23 America/New_York] PHP Parse error: syntax error, unexpected 'Namespace' (T_NAMESPACE), expecting identifier (T_STRING) in /home/bavnbzjp/wiki/includes/Namespace.php on line 52 [25-Jul-2014 20:06:26 America/New_York] PHP Parse error: syntax error, unexpected 'Namespace' (T_NAMESPACE), expecting identifier (T_STRING) in /home/bavnbzjp/wiki/includes/Namespace.php on line 52 So, I have restored the original wiki folder as you left and copied the upgrade tried folder as "wiki-tried-update"

I am also not getting a solution for the same from mediawiki forums for this. I would suggest you to submit the issue to MediaWiki support at http://www.mediawiki.org/wiki/Project:Support_desk for the suggestions from them.

Is there a way to COMPLETELY reinstall mediawiki and then point to my old database? What do you guys suggest? As it stands now, my wiki is simply showing a blank white page: wiki.arcknight.com

This post was posted by Johs~mediawikiwiki, but signed as Johs.

The class is designed for PHP version 5.3+, it includes new specifications like namespaces. If you use an older version, like PHP 5.2, it can work until you remove these specifications. See how to install and use the class depending of your PHP version:

PHP 5.3+ with an autoloader

The PHPImageWorkshop folder added in your lib directory, just use the class namespace in your main script and that's it:

// myscript.php: use PHPImageWorkshop\ImageWorkshop; $layer = new ImageWorkshop(array(...));

PHP 5.3+ without autoloader

If you don't use an autoloader, this is a little more tricky but still easy to install: you just need to include files manually.

1 - Include ImageWorkshopException

You have to load ImageWorkshopException class at the beginning of ImageWorkshop file with include() or require_once() functions:

// ImageWorkshop.php: require_once('ImageWorkshopException.php'); // Adapt the correct path, here ImageWorkshopException.php and ImageWorkshop.php are in the same folder

If you don't do that, when using ImageWorkshop not correctly, an error like that will be displayed instead of an exception:

Fatal error: Class 'PHPImageWorkshop\ImageWorkshopException' not found in /home/.../ImageWorkshop.php on line 1731

2 - Include ImageWorkshop in your main script

Where you need to use the class don't forget to include it !

// myscript.php: require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class

3 - Usage

You can now initialize an object like this:

// myscript.php: $layer = new PHPImageWorkshop\ImageWorkshop(array(...));

Alternatively, a better thing is to use the namespace:

// myscript.php: use PHPImageWorkshop\ImageWorkshop; // Use the namespace of ImageWorkshop require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class

By this way, you can initialize an object simplier:

// myscript.php: // previous code ... $layer = new ImageWorkshop(array(...));

PHP 5.2 & older versions

Even its not advisable to use ImageWorkshop on an old PHP version, the class can work if you remove all the specifications of 5.3, especially namespaces.

Without clearing files, you will have some parse errors like that:

Parse error: syntax error, unexpected T_STRING in /home/.../ImageWorkshop.php on line 3 // Or also: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/.../index.php on line 5

This is normal: old PHP versions don't recognized namespaces so they consider them as parse errors or illegal characters !

Add PHPImageWorkshop folder in your project and lets do this !

1 - Clear ImageWorkshopException.php file

Remove the namespace declaration line 3:

namespace PHPImageWorkshop;

Remove also the backslash ("\") before Exception line 10:

class ImageWorkshopException extends \Exception

2 - Clear ImageWorkshop.php file

Open ImageWorkshop.php file, and then remove the namespace declaration line 3:

namespace PHPImageWorkshop;

And the namespace inclusion line 5:

use PHPImageWorkshop\ImageWorkshopException;

Then, with your text editor, replace all the founded occurences "static::" by "self::".

And also "new static" by "new self".

This is because late static binding only exists since 5.3 !

3 - Include ImageWorkshopException

You have to load ImageWorkshopException class at the beginning of ImageWorkshop file with include() or require_once() functions:

// ImageWorkshop.php: require_once('ImageWorkshopException.php'); // Adapt the correct path, here ImageWorkshopException.php and ImageWorkshop.php are in the same folder

If you don't do that, when using ImageWorkshop not correctly, an error like that will be displayed instead of an exception:

Fatal error: Class 'PHPImageWorkshop\ImageWorkshopException' not found in /home/.../ImageWorkshop.php on line 1731

4 - Include ImageWorkshop in your main script

The last thing, where you need to use the class don't forget to include it !

// myscript.php: require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class

5 - Usage

You can now use the class classically:

// myscript.php: $layer = new ImageWorkshop(array(...));

Parse error: syntax error, unexpected T_STRING #18

I thought about doing it, but the service is sucky anyway. I am installing WAMP and running the scripts locally.

Thanks so much for your time, your help has been invaluable.

From: Sam Sullivan [mailto:[email protected]]
Sent: 14 de outubro de 2013 00:58
To: Mashape/unirest-php
Cc: CleverBeast
Subject: Re: [unirest-php] Parse error: syntax error, unexpected T_STRING (#18)

I recommend chatting with your hosting service and seeing if there is any way you can upgrade.

Otherwise, you can replace the <?php namespace Unirest; with <?php on the first line of the files in /lib/Unirest/. This isn't the best solution though because 1, you may reach class collision if you include other libraries, and 2, you won't easily be able to upgrade Unirest from git.


Reply to this email directly or view it on GitHub #18 (comment) . https://github.com/notifications/beacon/vOaa6pFI-n2mffiuEsgYQJrg3DxZmuK_ABVHNPDNNmp66y9lEeADu3fLukJ5iH-D.gif


Não foram detetados vírus nesta mensagem.
Verificado por AVG - www.avg.com
Versão: 2013.0.3408 / Base de dados de Vírus: 3222/6746 - Data de Lançamento: 10/13/13

Syntax Error Unexpected 3939 Expecting 3939

syntax error, unexpected ',', expecting ')'

Tags: rubysyntax-errorruby-1.9 Answers: 1 Viewed 40,493 times



I just installed Ruby 1.9.2 after having used 1.8.7, as php 5.2 namespace syntax error unexpected t_string is a feature I need. I had called many of my methods like this:



With 1.9.2, i get the following error, and the fix seems to be:



But this could take me hours to fix all the cases. Is there a way around this? Why is it an error in the first place? thanks



Paweł Obrok Paweł Obrok answer at 2011-12-17 42



The extra space is the culprit. Use:



* The answers/resolutions are collected from stackoverflow, are licensed under CC BY-SA 3.0

Some Code Answers






More Answers Related Syntax Error Unexpected 3939 Expecting 3939

Parse error: syntax error, php 5.2 namespace syntax error unexpected t_string, unexpected &#39;,&#39;, expecting

6 days ago Dec 24, 2019  · Home MySQL Parse error: syntaxerror, unexpected ',', expecting ')' in C:\xampp\htdocs\script\includes\application_top.php on line 7 [duplicate] LAST …

Show details

See also: Php

syntax error, unexpected '__data' (T_STRING), expecting ',' or .

1 week ago I would need to solve this problem, when I press the record button, the program should bring me on the page of the user who has just registered but I get this error: ERROR: syntaxerror, …

Show details

Parse error: syntax error, unexpected &#39;::&#39; (T_PAAMAYIM .

4 days ago Parse error: syntaxerror, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM), expecting ')' [duplicate] 166. January 16, 2019, at 10:40 PM. This question already has an answer here: …

Show details

Syntax error: word unexpected (expecting ")") - Stack …

1 week ago Apr 18, 2016  · dash -c 'myfunc ( something' php 5.2 namespace syntax error unexpected t_string 1: Syntax error: word unexpected (expecting ")") One case where that can happen is if the script has been written on or transferred through …

Reviews: 2

Show details

Parse error: syntax error, unexpected &#39;,&#39;, expecting :: (T .

3 days ago Here's my code, I got this error: Parse error: syntaxerror, unexpected ',', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in E:\xampp\htdocs\cms\admin\submit_post.php on line 68

Show details

See also: Php

ruby - syntax error, unexpected ',', expecting ')' - Stack …

1 week ago Dec 17, 2011  · 15. I just installed Ruby 1.9.2 after having used 1.8.7, php 5.2 namespace syntax error unexpected t_string, as there is a feature I need. I had called many of my methods like this: do_something (arg0, arg1) With 1.9.2, i get the …

Show details

See also: Ruby

syntax error, unexpected $end, expecting keyword_end

2 days ago Feb 12, 2013  · Teams. Q&A for work. Connect and share knowledge within a single location that is structured and easy to search. Learn more about Teams

Show details

Syntaxfehler, unerwartet ':', erwartet Keyword_then - Ruby-On …

1 week ago Gem-Syntaxfehlerfragen - Syntax, Gem, Gemfile Ruby SyntaxError: Unerwartetes Eingabeende, erwartet keyword_end [closed] - ruby ungerade Zahlenliste für Hash auf sehr einfaches Skript …

Show details

See also: Ruby List File

構文エラー、予期しない ':'、expecting keyword_then - ruby -on …

1 week ago 構文エラー、予期しない ':'、expecting keyword_then - ruby -on-rails、ruby、syntax、rvm 私は新しいプロジェクトを作成しようとし、「$ rails new testx」を実行しましたが、以下の …

Show details

See also: Ruby

Parse-Fehler: Syntaxfehler, unerwartetes '}', Erwarten von ',' oder .

1 week ago Immer wenn ich diesen Code unten ausführe, erhalte ich einen Parse-Fehler: Syntaxfehler, unerwartet, erwartet oder; in C: wampwwwbeehivedetails.php in Zeile 52. Ich habe mir den …

Show details

See also: Php

PSR-0オートローダ - php、構文、str-replace、autoloader、psr-0 …

1 week ago 構文エラー、予期しない ':'、expecting keyword_then - ruby -on-rails、ruby、syntax、rvm どのように私はレールにruby-on-railsのlink_toにクラスを追加できますか? Ruby / ROR - 構文 …

Show details

See also: Php Ruby-on-rails Ruby

Erro de análise: erro de sintaxe, inesperado '}', esperando ',' ou ., php 5.2 namespace syntax error unexpected t_string.

3 days ago Sempre que executo esse código abaixo, recebo o erro de análise: erro de sintaxe, inesperado, esperado ou; em C: wampwwwbeehivedetails.php na linha 52. Eu olhei o código e (para mim) …

Show details

See also: Php

Please leave your answer here:

Tagged MediaWiki, PHP, troubleshooting

After upgrading my PHP to 5.3.2, I received the following error when accessing MediaWiki (1.6.12):Parse error: syntax error, unexpected T_NAMESPACE, expecting T_STRING in /usr/local/www/apache22/data/wiki/includes/Namespace.php on line 46

There are three solutions:

  1. Downgrade your PHP from 5.3 back to 5.2
  2. Upgrade your MediaWiki to a newer version.
  3. Fix the codes.

In my case, the first couple solutions do not work for me, and therefore I choose 3.

  1. Backup your wiki file first.
  2. Access your webserver and go to the MediaWiki/includes directory.
    For example:cd /usr/local/www/apache22/data/wiki/includes
  3. Edit Namespace.phpnano Namespace.php
  4. Go to line 46, change the following from: class Namespace {

    to:

    class MWNamespace {

    Save the file.

  5. Now, let’s create a script: nano wikifix.sh

    Copy and paste the following:

    for fl in *.php; do mv $fl $fl.old sed 's/Namespace::/MWNamespace::/g' $fl.old > $fl done

    Save the file.

  6. Change the file to executable by: chmod u+x wikifix.sh
  7. Search the keyword Namespace:: and replace it by MWNamespace::: ./wikifix.sh

    Warning: Don’t run the script twice!

  8. Delete the script. rm wikifix.sh

Try to access the MediaWiki again and the problem should be gone.

Enjoy Wiki.

–Derrick

Our sponsors:

Related

Posted in Computer Problems, Server Problems, Technology, php 5.2 namespace syntax error unexpected t_string, Troubleshooting

The class is designed for PHP version 5.3+, it includes new specifications like namespaces. If you use an older version, like PHP 5.2, it can work until you remove these specifications. See how to install and use the class depending of your PHP version:

PHP 5.3+ with an autoloader

The PHPImageWorkshop folder added in your lib directory, just use the class namespace in your main script and that's it:

// myscript.php: use PHPImageWorkshop\ImageWorkshop; $layer = new ImageWorkshop(array(.));

PHP 5.3+ without autoloader

If you don't use an autoloader, this is a little more tricky but still easy to install: you just need to include files manually.

1 - Include ImageWorkshopException

You have to load ImageWorkshopException class at the beginning of ImageWorkshop file with include() or require_once() functions:

// ImageWorkshop.php: require_once('ImageWorkshopException.php'); usr/bin/ssh-copy-id error no identities found Adapt the correct path, here ImageWorkshopException.php and ImageWorkshop.php are in the same folder

If you don't do that, when using ImageWorkshop not correctly, an error like that php 5.2 namespace syntax error unexpected t_string be displayed instead of an exception:

Fatal error: Class 'PHPImageWorkshop\ImageWorkshopException' not found in /home/./ImageWorkshop.php on line 1731 php 5.2 namespace syntax error unexpected t_string

2 - Include ImageWorkshop in your main script

Where you need to use the class don't forget to include it !

// myscript.php: require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class

3 - Usage

You can now initialize an object like this:

// myscript.php: php 5.2 namespace syntax error unexpected t_string $layer = new PHPImageWorkshop\ImageWorkshop(array(.));

Alternatively, a better thing is to use the namespace:

// myscript.php: use PHPImageWorkshop\ImageWorkshop; // Use the namespace of ImageWorkshop require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class

By this way, you can initialize an object simplier:

// myscript.php: // previous code . $layer = new ImageWorkshop(array(.));

PHP 5.2 & older versions

Even its not advisable to use ImageWorkshop on an old PHP version, the class can work if you remove all the specifications of 5.3, especially namespaces.

Without clearing files, you will have some parse errors like that:

Parse error: syntax error, unexpected T_STRING in /home/./ImageWorkshop.php on line 3 // Or also: Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/./index.php on line 5

This is normal: old PHP versions don't recognized namespaces so they consider them as parse errors or illegal characters !

Add PHPImageWorkshop folder in your project and lets do this !

1 - Clear ImageWorkshopException.php file

Remove the namespace declaration line 3:

namespace PHPImageWorkshop;

Remove also the backslash ("\") before Exception line 10:

class ImageWorkshopException extends \Exception

2 - Clear ImageWorkshop.php file

Open ImageWorkshop.php file, and then remove the namespace declaration line 3:

namespace PHPImageWorkshop;

And the namespace inclusion line 5:

use PHPImageWorkshop\ImageWorkshopException;

Then, with your text editor, replace all the founded occurences "static::" by "self::". php 5.2 namespace syntax error unexpected t_string And also "new static" by "new self".

This is because late static binding only exists since 5.3 !

3 - Include ImageWorkshopException

You have to load ImageWorkshopException class at the beginning of ImageWorkshop file with include() or require_once() functions:

// ImageWorkshop.php: require_once('ImageWorkshopException.php'); // Adapt the correct path, here ImageWorkshopException.php and ImageWorkshop.php are in the same folder

If you don't do that, when using ImageWorkshop not correctly, an error like that will be displayed instead of an exception:

Fatal error: Class 'PHPImageWorkshop\ImageWorkshopException' not found in /home/./ImageWorkshop.php on line 1731

4 - Include ImageWorkshop in your main script

The last thing, where you need to use the class don't forget to include it !

// myscript.php: require_once('path/to/lib/PHPImageWorkshop/ImageWorkshop.php'); // Be sure of the path to the class

5 - Usage

You can now use the class classically:

// myscript.php: $layer = new ImageWorkshop(array(.));
php 5.2 namespace syntax error unexpected t_string

Thematic video

Parse error: syntax error, unexpected } PHP Solved

0 Comments

Leave a Comment