Php Parse Error Syntax Error Unexpected T_new
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn
Syntax Error, Unexpected 'new' (t_new) Php7
more about Stack Overflow the company Business Learn more about hiring developers or syntax error unexpected 'new' (t_new) php 7 posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community php 7 parse error: syntax error, unexpected 'new' (t_new) Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why am I getting an unexpected T_NEW error in PHP?
Cacti Php 7
up vote 1 down vote favorite I created a user model in Code Igniter. class User extends CI_Model { function __construct() { parent::__construct(); } public function new($username, $email, $password, $studentID="") { $this->db->query("INSERT INTO user VALUES (0, '$username', '$email', '$password', '$studentID')"); } } However, I am getting this PHP error. Parse error: syntax error, unexpected T_NEW, expecting T_STRING in /home/davidfaux/testApp/application/models/user.php on line 12 Line 12, by the way, is
Call To Undefined Function Set_magic_quotes_runtime
this line. public function new($username, $email, $password, $studentID="") { What is a T_NEW? Why am I getting the error? php codeigniter share|improve this question asked Mar 5 '12 at 23:16 David Faux 7,2001366133 2 public function new should be public function newUser. New is for creating instances of classes. And the keyword cannot be used as a function name. BTW Isn´t your code highlighting already telling you this? –PeeHaa Mar 5 '12 at 23:17 add a comment| 2 Answers 2 active oldest votes up vote 10 down vote accepted new is a reserved word for creating new objects, like new Person('Joe'). You should rename your function. See http://php.net/manual/en/reserved.keywords.php for reference. These words have special meaning in PHP. Some of them represent things which look like functions, some look like constants, and so on--but they're not, really: they are language constructs. You cannot use any of the following words as constants, class names, function or method names. Using them as variable names is generally OK, but could lead to confusion. share|improve this answer answered Mar 5 '12 at 23:18 biziclop 11.1k12750 1 php.net/manual/en/reserved.keywords.php –Matt H. Mar 5 '12 at 23:20 add a comment| up vote 2 down vote The new func
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads wordpress php 7 with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Ubuntu 16.04 Php5
Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign wordpress php7 up Parse error: syntax error, unexpected 'new' (T_NEW) in …/test6_2.php on line 20 up vote 0 down vote favorite Just trying to save and fix sources from PHPBench.com and hit this error (the site is down and the author didn't respond http://stackoverflow.com/questions/9575590/why-am-i-getting-an-unexpected-t-new-error-in-php to questions). This is the source: http://stackoverflow.com/questions/38675762/parse-error-syntax-error-unexpected-new-t-new-in-test6-2-php-on-line-2 ?> Is it a valid syntax or not? Correct me if I'm wrong but think it creates a reference to SomeClass, so we can call new $obj() ... Thanks in advance for the help php reference operators share|improve this question edited Jul 30 at 15:58 asked Jul 30 at 15:51 1000Gbps 90314 =& new ... is an invalid syntax –Charlotte Dunois Jul 30 at 15:55 The class instance needs to be assigned to a variable, so you have to assign the instance to a variable and then put the reference to the variable to $obj, but my question is, why do you need a reference? –Charlotte Dunois Jul 30 at 15:57 This is the test - comparison between = new and =& new when creating a new object –1000Gbps Jul 30 at 16:00 3 The syntax is since PHP 5.0 deprecated and got removed in PHP 7.0. PHP 5.0 says Strict Standards: Assigning the return value of new by reference is deprecated 3v4l.org/AKH8r –Charlotte Dunois Jul 30 at 16:01 Well, it's weird why PHP7 installation won't output when something is deprecated. Are they removed that in error_reporting(-1) mode in scripts and ~E_DEPRECATED added next to E_ALL in php.ini? –1000Gbps Jul 30 at 16:18 | show 5 more comments 1 Answer 1 active oldest votes up vote 0 down vote Objects are always stored by reference anyway. You don't need =& and as Charlotte commented, it's deprecated syntax. Correct m
Hacks » The plugin doesn't work on PHP version 7 The plugin doesn't work on PHP version https://wordpress.org/support/topic/the-plugin-doesnt-work-on-php-version-7/ 7 cuongvu @cuongvu 9 months ago Dear-, I install PHP version 7 and get this error: Parse error: syntax error, unexpected ‘new' (T_NEW) in http://www.frihost.com/forums/vt-62176.html wordpress\wp-content\plugins\exec-php\exec-php.php on line 22 Could you please upgrade this plugin to fix it? Thank you. https://wordpress.org/plugins/exec-php/ Viewing 7 replies - 1 through 7 syntax error (of 7 total) semky @semky 8 months, 3 weeks ago I use ezphp plugin with 1and 1 . still working but I did have to halt / rename a few plugings to get my site past all the errors. at startup. ditler @ditler 5 months ago In unexpected 'new' (t_new) exec-php.php, includes/admin.php, includes/ajax.php, includes/cache.php, includes/config_ui.php, includes/const.php replace any =& new by = new. And the plugin works like a charm again. peter_quinn @peter_quinn 1 month, 2 weeks ago @ditler‘s solution worked for me. However, I also needed to replace =& new with = new in includes/manager.php. naufal66262 @naufal66262 1 month, 1 week ago thx Fabian @carmano 3 weeks, 4 days ago I will do the manual fix, but it will be great to have a new official version of this plugin! I got the following report from another plugin: FILE: exec-php/includes/option.php --------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE --------------------------------------------------------- 29 | ERROR | Deprecated PHP4 style constructor are not supported since PHP7 --------------------------------------------------------- FILE: exec-php/includes/script.php --------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE --------------------------------------------------------- 20 | ERROR | Deprecated PHP4 style constructor are not supported since PHP7 --------------------------------------------------------- FILE: exec-php/includes/usermeta.php -------------------------------------------
get the following error Parse error: syntax error, unexpected T_NEW in /home/mproduct/domains/m-productions.frih.net/public_html/php/db_fns.php on line 7 Here is db_fns.php Code: whats wrong with this, im still very very new to php, i was using a book when making this script. it looks just like whats in the book SlowWalkere Are you running this script on friHost's servers? I think that mysqli and exceptions are new to PHP 5, but friHost is only running PHP 4.4. Because of that, either the mysqli call or the "throw new Exception" are screwing up the server and creating a parsing error. If you're running it somewhere else, check the version of php by going to the phpinfo.php page on the server. If that's not it, then I'm all out of ideas. Hopefully someone else knows more... Good luck, - Walkere m-productions yeah the book im using is for php 5 ..... meaning msqli is the problem... well thats not good, the main reason i came to this host was to get all my php working...... errrf anyway... if i cant use mysqli then how do i make the script, beacuse thats how my book always does it... hexkid throw is not part of PHP 4. It only works for PHP 5 or greater. You can use mysqli on PHP >= 4.1 m-productions hexkid wrote: throw is not part of PHP 4. It only works for PHP 5 or greater. You can use mysqli on PHP >= 4.1 then what should i use instead of throw, this also is used in a few areas. actully, it seems there even more php 5 based things that its using..... i duno what im gana do, i guess i need to find another host just to host my php files on... o.0 hexkid m-productions wrote: then what should i use instead of throw, this also is used in a few areas. Use "standard" procedural programming insted Code: