Php Parse Error Parse 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 more syntax error, unexpected 'new' (t_new) php7 about Stack Overflow the company Business Learn more about hiring developers or posting ads
Syntax Error Unexpected 'new' (t_new) Php 7
with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack php 7 parse error: syntax error, unexpected 'new' (t_new) 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? up vote
Parse Error: Syntax Error, Unexpected T_string
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 this line. public cacti php 7 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 function is a reserved keyword for in
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and
Call To Undefined Function Set_magic_quotes_runtime
policies of this site About Us Learn more about Stack Overflow the
Wordpress Php 7
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users ubuntu 16.04 php5 Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes http://stackoverflow.com/questions/9575590/why-am-i-getting-an-unexpected-t-new-error-in-php a minute: Sign up PHP Parse/Syntax Errors; and How to solve them? up vote 206 down vote favorite 108 Everyone runs into syntax errors. Even experienced programmers make typos. For newcomers it's just part of the learning process. However, it's often easy to interpret error messages such as: PHP Parse error: syntax error, unexpected '{' in index.php on line 20 The unexpected http://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them symbol isn't always the real culprit. But the line number gives a rough idea where to start looking. 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. While not every case matches the other. Yet there are some general steps to solve syntax mistakes. This references summarized the common pitfalls: Unexpected T_STRING Unexpected T_VARIABLE Unexpected '$varname' (T_VARIABLE) Unexpected T_CONSTANT_ENCAPSED_STRING Unexpected T_ENCAPSED_AND_WHITESPACE Unexpected $end Unexpected T_FUNCTION… Unexpected { Unexpected } Unexpected ( Unexpected ) Unexpected [ Unexpected ] Unexpected T_IF Unexpected T_FOREACH Unexpected T_FOR Unexpected T_WHILE Unexpected T_DO Unexpected T_PRINT Unexpected T_ECHO Unexpected T_INLINE_HTML… Unexpected T_PAAMAYIM_NEKUDOTAYIM… Unexpected T_OBJECT_OPERATOR… Unexpected T_DOUBLE_ARROW… Unexpected T_SL… Unexpected T_BOOLEAN_OR… Unexpected T_BOOLEAN_AND… Unexpected T_IS_EQUAL Unexpected T_IS_GREATER_OR_EQUAL Unexpected T_IS_IDENTICAL Unexpected T_IS_NOT_EQUAL Unexpected T_IS_NOT_IDENTICAL Unexpected T_IS_SMALLER_OR_EQUAL Unexpected < Unexpected > Unexpected T_NS_SEPARATOR… Unexpected character in input: '\' (ASCII=92) state=1 Unexpected 'public' (T_PUBLIC) Unexpected 'private' (T_PRIVATE) Unexpected 'protected' (T_PROTECTED) Unexpected 'final' (T_FINAL)… Unexpected T_STATIC… Unexpected T_CLASS… Unexpected T_DNUMBER Unexpected , (comma) Unpexected . (period) Unexpected ; (semicolon) Unexpected * (asterisk) Unexpected : (c
and Objects Namespaces Errors Exceptions Generators References Explained Predefined Variables Predefined Exceptions Predefined Interfaces and Classes Context options and parameters Supported Protocols http://php.net/manual/en/migration70.incompatible.php and Wrappers Security Introduction General considerations Installed as CGI binary http://www.frihost.com/forums/vt-62176.html Installed as an Apache module Session Security Filesystem Security Database Security Error Reporting Using Register Globals User Submitted Data Magic Quotes Hiding PHP Keeping Current Features HTTP authentication with PHP Cookies Sessions Dealing with XForms Handling file uploads Using remote files syntax error Connection handling Persistent Database Connections Safe Mode Command line usage Garbage Collection DTrace Dynamic Tracing Function Reference Affecting PHP's Behaviour Audio Formats Manipulation Authentication Services Command Line Specific Extensions Compression and Archive Extensions Credit Card Processing Cryptography Extensions Database Extensions Date and Time Related Extensions File System Related Extensions Human Language and syntax error, unexpected Character Encoding Support Image Processing and Generation Mail Related Extensions Mathematical Extensions Non-Text MIME Output Process Control Extensions Other Basic Extensions Other Services Search Engine Extensions Server Specific Extensions Session Extensions Text Processing Variable and Type Related Extensions Web Services Windows Only Extensions XML Manipulation GUI Extensions Keyboard Shortcuts? This help j Next menu item k Previous menu item g p Previous man page g n Next man page G Scroll to bottom g g Scroll to top g h Goto homepage g s Goto search(current page) / Focus search box New features » « Migrating from PHP 5.6.x to PHP 7.0.x PHP Manual Appendices Migrating from PHP 5.6.x to PHP 7.0.x Change language: English Brazilian Portuguese Chinese (Simplified) French German Japanese Korean Romanian Russian Spanish Turkish Other Edit Report a Bug Backward incompatible changes Changes to error and exception handling Many fatal and recoverable fatal errors have been converted to excepti
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: