Parse Error with Wordpress Template - broke my site [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
Parse error: syntax error, unexpected '[' in
/home/content/90/12894990/html/wp-content/plugins/levelup-core/admin/metaboxes/config-meta-boxes.php
on line 261
I downloaded and opened the file in Dreamweaver and it's telling me there's actually a syntax error on line 521 which is:
'visible' => [$prefix . 'header_transparent', 'in', [1]]
can anyone help me with this? Cause it's made the entire wordpress site inaccessible, kinda driving me nuts.

You're probably using a PHP version before version 5.4, in which the short array syntax was added.
New features introduced include:
Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.

To really solve this problem i need a bigger piece of code. But it seems like a wrong declaration of an array. In the line you posted replace the block quotes for proper quotation:
'visible' => $prefix . 'header_transparent', 'in', 1
Might not solve the entire problem, but its the best i can do with just this line.

Related

PHP 5.3 - unexpected [ [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
I am trying to get a WordPress site working on a server running PHP 5.3. I am not able to update the server so am trying to make things compatible.
I am getting the following error...
Parse error: syntax error, unexpected '['
The line that is causing the error is...
echo wp_get_attachment_image($mysection['imageid'], 'medium', "", ["class" => "side_img"] );
Any ideas how to modify this code to be compatible?
The short array syntax was first introduced in PHP 5.4. PHP 5.3 does not understand what ["class" => "side_image"] is, hence the syntax error.
The solution is simple, change:
["class" => "side_image"]
into:
array("class" => "side_image")
PHP 5.3 does not support the "short array syntax" like [1, 2, 3, 4]. These must be converted to array(1,2,3,4).
See here: http://php.net/manual/en/migration54.new-features.php

Syntax error while trying to use paymentwall example [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 4 years ago.
Syntax error while using this code , An example from paymentwall
$widget = new Paymentwall_Widget(
''. $_SESSION['PLR_ACCOUNT']['PLR_ID'] .'',
'p10_1',
array(
new Paymentwall_Product(
'product2',
9.99,
'USD',
'Elite 3 months',
Paymentwall_Product::TYPE_SUBSCRIPTION,
1,
Paymentwall_Product::PERIOD_TYPE_MONTH,
true
),
array(
'email' => 'user#hostname.com',
'history[registration_date]' => 'registered_date_of_user',
'ps' => 'all'
)
echo $widget->getUrl();
)
}
Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ')'
in C:\Users\Arlindi\Desktop\X-Portal - V2.6.8 -
FINAL\test-server\root\pages\premium_info.php on line 301
Line 301 is
echo $widget->getUrl();
How to solve it ?
Look at your code context!
When you get syntax error it means you have typo or your code is somehow wrong
as in PHP parse/syntax errors; and how to solve them? explained when you see syntax error,
Always look at the code context. The syntax mistake often hides in the mentioned or in previous code lines. Compare your code against
syntax examples from the manual.
In your example you used echo in your function argument and after array(...)
It is not right in php
function(array(...)echo something;) is not correct syntax in php
As you didn't say what you want your code actually do, I don't know what can be your correct code but I guess you should close Paymentwall_Widget() parentheses before echo and put one semicolon after the parentheses before echo line

Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
Hey I am trying to add a customize option in a wordpress theme that allows for the user to upload there own image in in a showcase but im getting a syntax error in my customize.php file. Can any one help me write this the correct way? thanks!
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in /Applications/XAMPP/xamppfiles/htdocs/wordpress/wp-content/themes/wpbootstrap/inc/customizer.php on line 13
$wp_customize->add_setting('showcase_image', array(
'default' => get_bloginfo('template_directory').'/img/showcase.jpg', 'wpbootstrap'),
line 13 'type' => 'theme_mod'
));
Without spoon feeding the answer (as requested to #community above), but giving a re-usable technique to find these types of bugs ...
Temporarily reformat your code so all function paramters and/or array elements are on their own line and using identing appropriately. Eventually you'll likely see something that is not what you intended. Example below (you're almost there).
$wp_customize->add_setting(
'showcase_image', // func parm
array(
'default' => get_bloginfo(
'template_directory'
).'/img/showcase.jpg',
'wpbootstrap'
),
'type' => 'theme_mod'
)
);

Parse error: syntax error, unexpected '[' & functions_main.php on line 1114 [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Im installing my Wordpress theme and when I click activate I get the following error:
Parse error: syntax error, unexpected '[' in E:\Websites\HostingSpaces\mov1\movies.in\wwwroot\wp-content\themes\wp_mov\functions_main.php on line 1114
Anyone have any idea of how fix it?
This is caused by new-style array initialization ("short array syntax"), introduced in PHP 5.4:
<?php
$myArray = ["one", "two", "three"];
$myAssociativeArray = [
"key1" => "value1",
"key2" => "value2",
];
You'll have to upgrade to PHP 5.4 or better. If you let me know what OS you're using, I can provide specific instructions.
More info can be found in the array type manual.

PHP Parse error: syntax error, unexpected '[' [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
Recently I moved my website from localhost to a url domain, and now it keeps showing the errors above. The lines with problems are shown bellow. I think it's because the sintax that I used is from a more recent version of PHP, but I can't find any specific documentation for previous versions.
<?php echo explode(' ', $_SESSION['usuario_nome'])[0]; ?>
...
$fields_holder += [$name => $table_info[$i][$name]];
What is the equivalent of those lines of code to PHP < 5.4?
Can anybody think of any other reason the code suddenly stopped working?
Sorry about my bad english...
PHP5.3 does not support the short array syntax, it is new in PHP5.4
The syntax that should work in PHP < 5.4 and in PHP5.4 and > is
<?php
$t = explode(' ', $_SESSION['usuario_nome']);
echo $t[0];
$fields_holder[] = array($name => $table_info[$i][$name]);
But I would guess that there is going to be more code that you are going to have to refactor if you have implemented this code on a server that is running PHP5.3
In previous version you have to use old double-line syntax:
$array = explode(' ', $_SESSION['usuario_nome']);
echo $array[0];
$array = array( $name => $table_info[$i][$name] );
The += syntax with array is unsupported even in PHP > 5.3

Categories