Wordpress functions.php has a parse error [duplicate] - php

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Hi I ran into a prob while setting up the functions.php file for Wordpress. My localhost server is showing this error: Parse error: syntax error, unexpected 'if' (T_IF) in /Applications/MAMP/htdocs/wdnomads-wp/wp-content/themes/womendigitalnomads/functions.php on line 3
I've tried googling and pasting Wordpress' own code, but the error still exists. Not sure what I'm doing wrong.
<? php
if ( ! isset( $content_width ) ) {
$content_width = 660;
}

What exactly is your question?
Your formatting should have no space before php

<? php should be <?php.

Try out this, just replace your code with following code :-
function prefix_content_width() {
$GLOBALS['content_width'] = apply_filters( 'prefix_content_width', 660 );
}
add_action( 'after_setup_theme', 'prefix_content_width', 0 );

Related

I can't get what's worng in this code it made website down [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 1 year ago.
I'm getting error in the PHP code it's a Wordpress custom theme, it made my website down.
PHP Syntax Check:
Parse error: syntax error, unexpected '$', expecting variable (T_VARIABLE) in your code on line 1
Here is the code:
$path = "/home/u921722263/domains/fallcomlegal.co/public_html/wp-content/!function($){$.easing.jswing=$.easing.swing,$.extend($.easing,{def:"easeOutQuad",swing:function(x,t,b,c,d){return $.easing[$.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){return(t/94256)}";
There is a Syntax errorin this part:
{return $.easing$.easing.def},
because $.easing is followed with a $ there should be a , or something else.
Try fixing this part.

Parse error: syntax error, unexpected 'if' (T_IF) [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
sorry , im newbie and bad at english , i google this problem still cant understand what is wrong , please help me !
i have this error
Parse error: syntax error, unexpected 'if' (T_IF)
my code
if ( ! isset( $content_width ) ) {$content_width:474} if ( ! function_exists( twentyfourteen_setup ) ) :
$content_width:474 should be $content_width=474;

vqcache/vq2-catalog_controller_common_header.php [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I am receiving this error message:
[17-Mar-2017 10:22:14 America/Detroit] PHP Parse error: syntax error, unexpected end of file in /home/smarthea/public_html/ocart/vqmod/vqcache/vq2-catalog_controller_common_header.php on line 50
Here is the end of my code in the vqcache PHP file:
$this->template = 'default/template/common/header.tpl'; }
{ $this->render(); }
?>
Which syntax am I missing?
See you modification-file. You just missed line number. Just look into instructions in modificator and correct it.
This error usually appear when you're using several vQmod mofificators that used same file. In you case they modify /catalog/controller/common/header.php

How can I fix that syntax error, unexpected T_STRING, expecting T_FUNCTION? [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
I use wordpress theme and I added some codes in functions.php . Here there: https://gist.github.com/tomhemsley/4d19646f57a0a1f20709
Then, I saw that:
Change this line
if ( $datas['tried'] <= $this->failed_login_limit )
to this
if ( $datas['tried'] <= $this->failed_login_limit ) {
You missed the opening brace for the if condition. Better you use good IDE so that these type of syntax errors will be resolved.

Fatal error: Can't use function return value in write context in /home/***/public_html/****.com/wp-content/themes/****/functions.php on line 652 [duplicate]

This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 7 years ago.
I'm getting this error and I do not know how to resolve
Fatal error: Can't use function return value in write context in /home/***/public_html/****.com/wp-content/themes/****/functions.php on line 652
Anybody knows what's going on???
Line 652 is:
if ( !empty( gamexls_get_option( 'hidecatbox', '' )) ) {
PS Here's the full function.php file, in case it helps:
See this pastebin http://pastebin.com/pyUKvMX5
-
Refer to empty manual which says:
Prior to PHP 5.5, empty() only supports variables; anything else will result in a parse error
So it should be:
$res = gamexls_get_option( 'hidecatbox', '' );
if ( !empty($res) ) {

Categories