WordPress site not launching because of a PHP error [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
I haven't opened my main domain for a month or so, and when I did, I got this error:
Parse error: syntax error, unexpected '.', expecting ')' in /home2/navidcs/public_html/4amir.com/wp-content/plugins/mojo-marketplace-wp-plugin/inc/cli-init.php on line 25
My site is based on WordPress, and I have never edited the PHP files, though I have messed around a lot with one of my sub domains, which is also using WordPress, but should not be related to my main domain.
Here is the link to the file that apparently has the error:
https://codeshare.io/Amirak

In PHP, "." is the concatenation operator. Normaly, you can break the line before or after this operator...
Please, try to replace
'longdesc' => 'Control the admin interface, default modules and UX for an Endurance hosting brand.' .
PHP_EOL . 'Subcommands: update, remove',
by
'longdesc' => 'Control the admin interface, default modules and UX for an Endurance hosting brand.' . PHP_EOL . 'Subcommands: update, remove',
and give the new error message.

Related

WordPress site with unending Parse Syntax Errors [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 2 years ago.
I am very new to coding - I was actually just trying to learn to edit an old website for a friend using WordPress, to make it more visually appealing and fresh.
Everything was way out of date, so I backed up the site, then started updating things in what I thought was the right order, but I was probably wrong since once I updated the plugins I got a Parse Syntax error and can't get into the wp-admin now.
I went through the steps in this tutorial (using FileZilla and Notepad++) to try and fix it, but it keeps giving me a new Parse Syntax error in the same file. Now I'm worried I'm just making things worse in there and I'm not certain what I should do.
The initial error was an unexpected "[" (or "]"? idr now...) on line 344, so I thought I needed to just get rid of it, but I don't think I was right. This is the error I have now, after trying to change things 2-3 times:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/content/67/14065667/html/wp-content/plugins/page-links-to/classes/plugin.php on line 346
Here is the section of coding I've been having issues in (lines 340-351):
public function enqueue_block_editor_assets() {
// Gutenberg.
if ( self::is_block_editor() && self::is_supported_post_type() ) {
wp_enqueue_script( 'plt-block-editor', $this->get_url() . 'dist/block-editor.js', array( 'wp-edit-post', 'wp-element', 'wp-plugins' ), self::CSS_JS_VERSION, true );
wp_localize_script( 'plt-block-editor', 'pltOptions',
'supports'
'newTab' => self::supports( 'new_tab' ),
],
]);
do_action( 'page_links_to_enqueue_block_editor_assets' );
}
}
What can I try to fix this?
Seems your argument list for wp_localize_script is malformed. It should be something like
wp_localize_script( string $handle, string $object_name, array $l10n )
Address that and you should be good. Without more context of what should belong to the $handle, $object_name and $l10n, can't fully type an answer to clear it up.
WP Localized Script Docs

PHP: xpath not working on php5.3 because of unexpected "[" [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I was running the following line on PHP5.4 without any problem:
$lstContent = $data->xpath("/response/lst[#name='highlighting']")[0]->lst[$i]->arr->str;
But now on PHP5.3 (production system) I get the following error:
Parse error: syntax error, unexpected '[' in /var/www/html/upload/inc_suche_code.php on line 153
Any ideas for a quick fix?
Updating PHP won't work for me.
In older versions of PHP you can not access array values directly on variables that are the result of a function. You have to split up the expression using a temporary variable.
$result = $data->xpath("/response/lst[#name='highlighting']");
$lstContent = $result[0]->lst[$i]->arr->str;
As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable.
Source: http://php.net/manual/en/language.types.array.php
Edit: Obligatory "you should also consider upgrading your PHP version". This annoying limitation was fixed ages ago, not to mention that the 5.3 had its end of life in 2014, meaning it has not received security upgrades since.

Unexpected end of file on custom Woocommerce template [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I'm coding a custom Woocommerce theme. All works well in local, but when I deploy on my server, this error occurs when I go to a product details:
Parse error: syntax error, unexpected end of file in /wp-content/themes/customtheme/content-single-product.php on line 231
Here's the concerned file code (Pastebin since it's a big amount of code and it display the lines number) : https://pastebin.com/bzgLQTmD
I really don't know where is this error given that I don't have it in local development.
I tried code validators, but they didn't gave me any clues.
The problem is with short tags, which are not enabled by default. So, either enable them from php.ini or
Change all of these:
<? endif; ?>
To Proper full tags like:
<?php endif; ?>

Syntax error when trying to put together constant and string [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Normally i wouldn't post syntax errors here, but this case is a bit suspicious to me. I was trying to put together a constant with a string. I works fine on localhost, but when i push my project on my web server, it tells me:
Parse error: syntax error, unexpected '.', expecting ',' or ';' in xxx on line xxx
Code:
define("ROOT", str_replace("index.php", "", $_SERVER["SCRIPT_FILENAME"]));
and
$somePath = ROOT . "some/path"; //Synax error in this line
Has this something to do with different PHP versions? (5.5 on webserver, 7.0 localhost)
Update
Some updates in the code:
class SomeClass {
private $somePath = ROOT . "some/path"; //Synax error in this line
...
}
You can't use str_replace() nor any function when defining a contant. Try:
define("ROOT", $_SERVER["SCRIPT_FILENAME"]);
$somePath = str_replace("index.php", "", ROOT) . "some/path";
Please refer to PHP Manual:
In PHP 5, value must be a scalar value (integer, float, string, boolean, or NULL). In PHP 7, array values are also accepted.

I'm writing in PHP for a church website, and keep getting a syntax error related to a string without any visible problems [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
The error is:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home2/svchapel/public_html/mmp_upgrade/administrator/components/com_sermonspeaker/s3/S3.php on line 1802
The line of code referenced is:
'code' => (string)$rest->response->body->Error->Code,
The line above the code referenced is:
$rest->response->error = array(
And the line below the code referenced is:
'message' => (string)$rest->response->body->Error->Message);
I can't find a problem in any of these lines... help?
Might be some odd, but invisible character there which ruins the PHP syntax (e.g., some sort of a fancy hyphen character instead of a regular one). I would try carefully re-typing the whole line manually in the plain text editor; if that doesn't help, I'd try to insert line breaks before each -> to see where exactly PHP borks up.

Categories