Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

.htaccess error

When trying to running my website online after migrating it from offline:

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in /home/advancew/sample.advance-web-studio.com/vendor/ramsey/uuid/src/functions.php on line 34

The same .htaccess works offline why it does not works online?

My hosting provider mentions that it is .htaccess script error

.htaccess

	<IfModule mod_rewrite.c>
		<IfModule mod_negotiation.c>
    	Options -MultiViews -Indexes
		</IfModule>

		RewriteEngine On

		# Handle Authorization Header
		RewriteCond %{HTTP:Authorization} .
		RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

		# Redirect Trailing Slashes If Not A Folder...
		RewriteCond %{REQUEST_FILENAME} !-d
		RewriteCond %{REQUEST_URI} (.+)/$
		RewriteRule ^ %1 [L,R=301]

		# Send Requests To Front Controller...
		RewriteCond %{REQUEST_FILENAME} !-d
		RewriteCond %{REQUEST_FILENAME} !-f
		RewriteRule ^ index.php [L]
</IfModule>

Any clue why?

0 likes
14 replies
laracoft's avatar
  1. The PHP error you have does not seem related to the .htaccess.

  2. Why do you think it is related?

  3. Show us the lines around line 34 of this file /home/advancew/sample.advance-web-studio.com/vendor/ramsey/uuid/src/functions.php

MarianoMoreyra's avatar

Hi @davy_yg

That's probably a problem with your PHP version. Check that you are using version >= 7.2.5.

If you've deploy on a shared hosting with cPanel, you can usually can easily change the PHP version from there, although you might need to do some other change on .htaccess to be sure that your web application is using the same version.

davy_yg's avatar
Level 27

The server uses : PHP version: 7.3.6

My local uses: PHP/7.2.24

The only problem now I have many websites on the server that works with PHP 7.3.6 version.

If I change the server into PHP 7.2 I am afraid the other website will not works.

Any idea how to make my current website works with PHP 7.3 ?

MarianoMoreyra's avatar

Just in case, throw a .php file with a call to phpinfo() in it and browse that file to see which PHP version shows.

I had this same problem with a server, which even verifying that it was configured to run with the latest PHP version available at that time, as it had different versions installed, for some reason the phpinfo() showed that the webserver for that particular domain was running PHP v5.x

davy_yg's avatar
Level 27

It is PHP Version 7.2.24 on localhost and it works!

My problem is migrating it to the server which uses PHP Version 7.3.6

MarianoMoreyra's avatar

@davy_yg in case it effectively shows an older version, you can try adding the following at the top of your .htaccess file:

AddHandler application/x-httpd-php73 .php .php5

to force that version for that particular folder / webapp

MarianoMoreyra's avatar

@davy_yg ok...if you are absolutely sure that's the only PHP version your server is running, then I'm out of ideas at this moment (2:45 am here hehe).

Hope you find the problem and sorry for the insistence :)

laracoft's avatar

@davy_yg you have to change something for sure, pick 1 below:

  1. Change server to 7.2.24, and check other websites if they are OK
  2. Change .htaccess and add AddHandler application/x-httpd-php72 .php .php5
  3. Look at /home/advancew/sample.advance-web-studio.com/vendor/ramsey/uuid/src/functions.php and change it

1 being the easiest and 3 being the harder.

davy_yg's avatar
Level 27

Using phpinfo() :

On the server - PHP Version 7.2.33

On local - PHP Version 7.2.24

Why the error still persist?

The version is almost the same

laracoft's avatar

Then your only option is #3.

  1. How are your PHP files transferred to the server?
  2. Please show /home/advancew/sample.advance-web-studio.com/vendor/ramsey/uuid/src/functions.php from the server and not your local copy.
Sinnbeck's avatar

Do you get the error when using a browser or when running artisan commands?

MarianoMoreyra's avatar

@laracoft line 34 on that file is this:

function v1($node = null, ?int $clockSeq = null): string

The only ? There is the nullable introduced in php 7.1 That’s why I’ve been insisting on the php version

MarianoMoreyra's avatar

As @sinnbeck asked, it’s important to know if the error is thrown at console or when browsing.

In case it’s browsing @davy_yg you should try adding the line I’ve suggested at your .htaccess file

In case it’s at console, you should try running php with the full path to the 7.3 (or 7.2) version

laracoft's avatar

@marianomoreyra good call. but it seems his server is actually not running PHP 7.2 or is there a toggle in php.ini?

Please or to participate in this conversation.