Parse Error OptimizePress 2 WP - php

Parse error: syntax error, unexpected 'OptimizePress_Install'
(T_STRING) in
/home/investor/public_html/wp-content/themes/optimizepress/lib/admin/install.php
on line 1
Getting this annoying error when I click on "Activate Theme". How do I get around this? Code is below on pastebin
http://pastebin.com/GJkL64d1

First of all it needs a space between <?php and class so change it to <?php class
The second reason is it failing is because it is a 1 line script (all goes is on one line).
The first time it meets a comment the rest of the script is commented out.
You can fix this by
Download the file where is it not a strange one line.
Remove all comments
Beautify the php (make currect spaces)

Related

A weird PHP file in which any instruction is a syntax error

I have a Web application in PHP which when / (or something else) of it is opened in a browser displays the following error in the browser: Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE) in /var/www/n_environment.php on line 3. The file n_environment.php is loaded with require_once 'n_environment.php'; in index.php. And also from different places. It contains just comments, calls to define (unconditional or guarded by if (!defined) and two assignments of arrays of strings to variables.
I thought maybe it's (indirectly) in a class but not in a method, which indeed PHP prohibits for require_once, but apparently that's not the problem here. If I put anything else as the first instruction, e.g. echo or an assignment, a similar error (with a different offending token) results.
If I comment out everything in the file except the initial <?php, the error changes to unexpected end of file.
And if I also remove the <?php, what I get in the browser is the file content (block comment with code inside) with â instead of new lines.
What are the possible, most likely reasons for such behaviour? And how to fix it?

How do I get this PHP function to work with usort()?

I copied and pasted the piece of code below from http://php.net/manual/en/function.usort.php :
<?php
function cmp($a,$b)
{    
return strcmp($a["fruit"], $b["fruit"]);
}
$fruits[0]["fruit"] = "lemons";
$fruits[1]["fruit"] = "apples";
$fruits[2]["fruit"] = "grapes";
usort($fruits, "cmp");
while (list($key, $value) = each($fruits)) {
echo "\$fruits[$key]: " . $value["fruit"] . "\n";
}
?>
At first it gave some error about the $b variable. Now the new incessant error is:
Parse error: syntax error, unexpected '{' in C:\xampp\htdocs\testsort.php on line 4
I'm thoroughly confused as to the problem here.
When I copied and pasted the code, some strange characters were part of it. These were invisible within notepad but revealed by VS Code IDE. Removing them allowed the code piece work.

(PHP,xampp) syntax error in every code I test

I get a " Parse error: syntax error, unexpected" error for whatever I print.
The error "Parse error: syntax error, unexpected '"test"' (T_CONSTANT_ENCAPSED_STRING) in C:\xampp\htdocs\firstfile\test.php on line 3"
The code I tested
<?php
 echo 'test';
 
?>
A basic code, but the error persist.
How to solve this problem?
Could it be that what you posted is not the actual file that is executed? Certainly that file is fine syntactically, so there must be some stupid mistake somewhere. I see that the faulty file is inside a folder firstfile. You are really sure this posted file is that file inside the folder?
What is especially outstanding here are the double quote chars in the error message which simply are not present in the file you posted.
When an error like this remains unchanged whatever you do, then typically you edit the wrong file.

Parse error: syntax error, unexpected T_LOGICAL_AND

I want to get variables defined in php.ini file and below is the line to do that.
$settings = parse_ini_file("php.ini");
It gives error
PHP Parse error: syntax error, unexpected T_LOGICAL_AND in path/of/file on line 218
That line in php.ini is
; <? and ?> tags as PHP source which should be processed as such. It's been
I think this is due to word and. But this line is a comment. So why is it giving this error?
Edit : Removing and from line in php.ini file solved issue. I don't know why it was causing problem. I changed line to
; <? n ?> tags as PHP source which should be processed as such. It's been
You made something wrong, I guess you included the file somewhere.
<?php tags in comments (or wherever) will not start a code section in an ini file meaning that parse_ini_file() will never start a PHP parser.
Steps to reproduce:
test.ini:
;<?php and ?>
a=1
test.php:
<?php
var_dump(parse_ini_file('test.ini'));
Output:
array(1) {
'a' =>
string(1) "1"
}
You see it works like a charm.
The error is not in php.ini, but somewhere about line 218 of your source file.
I dont see any comment lines
add // at the start of line or put that text in /* comment goes here*/
these brackets!

T_STRING error on line that just says <?php

So I'm writing a script in codeigniter, and I get the following error message:
Parse error: syntax error, unexpected T_STRING in /home/globalar/public_html/givinghusband.com/system/application/controllers/sizes.php on line 1
the only problem: the only thing on that line is this:
<?php
So I'm quite mysterified as to what's going on here? Have I typed PHP wrong or what?
There could be a problem with your editor when it updated the file. I just had this problem and the editor removed all line breaks.
If you are uncertain try opening your php file in another editor or use the Cpanel file manager to take a peak.
Or you may have an unterminated quote or statement on some previous line without an ending semicolon (;) . Check all files that are included before this one.
a bare <?php in the file leads to a parse error in php (don't ask). Try adding a whitespace or a newline after it
Sorry.A bit late but might helpful for others.Just looked at your question.Just use
<?
?>
instead of :
<?php
?>
and remove whitespaces/line breaks between your php open tag and class name .It will resolve this conflict.Ta

Categories