Cannot Redeclare Function Error
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 about Stack Overflow the company Business Learn more about php fatal error cannot redeclare function previously declared hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask how to redeclare function in php Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Fatal Error Cannot Redeclare Wordpress
Join them; it only takes a minute: Sign up PHP Fatal error: Cannot redeclare function up vote 10 down vote favorite 2 I have a function A in file B.inc line 2: function A() { ... line 10: }
Cannot Redeclare Function Wordpress
In the apache log: PHP Fatal error: Cannot redeclare A() (previously declared in B.inc:2) in B on line 10 php apache share|improve this question asked Mar 17 '11 at 1:37 Bruce Dou 1,46262545 add a comment| 6 Answers 6 active oldest votes up vote 14 down vote accepted I suppose you're using require "B.inc" in multiple parts? Can you try using require_once in all those instances instead? Seems like your B.inc is parsed twice. share|improve this answer answered Mar cannot redeclare php 17 '11 at 1:40 EboMike 52.8k14112132 add a comment| up vote 3 down vote I had a similar problem where a function entirely contained within a public function within a class was being reported as redeclared. I reduced the problem to class B { function __construct() { function A() { } } } $b1 = new B(); $b2 = new B(); The Fatal error: Cannot redeclare A() is produced when attempting to create $b2. The original author of the code had protected the class declaration from being redeclared with if ( !class_exists( 'B' ) ) but this does not protect the internal function A() from being redeclared if we attempt to create more than one instance of the class. Note: This is probably not the same problem as above BUT it's very similar to some of the answers in PHP Fatal error: Cannot redeclare class share|improve this answer answered May 13 '13 at 22:00 bobbingwide 463 This is similar to a problem I had, but my issue was having a named function defined inside a foreach loop. The solution ended up being using an anonymous function instead. –Mike Lyons Dec 1 '14 at 20:12 The basic answer for me was: Don't define a function inside a another function. –Daniel Tonon Jul 1 '15 at 3:19 add a comment| up vote 2 down vote Did you already declare A()
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
Php Fatal Error Cannot Redeclare Class
Us Learn more about Stack Overflow the company Business Learn more about hiring fatal error cannot redeclare function previously declared in developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the drupal cannot redeclare Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up PHP error - cannot redeclare http://stackoverflow.com/questions/5333907/php-fatal-error-cannot-redeclare-function function up vote 6 down vote favorite 2 I have a JavaScript function making a call to a PHP script. So far so good. A problem happens when I try to do this: $hike_id = mysql_real_escape_string($_GET['hike_id']); When I import my connection file, it gives me an error that the functions in that file have already been defined and the error is this: [Fri Jun 10 12:34:43 http://stackoverflow.com/questions/6309524/php-error-cannot-redeclare-function 2011] [error] [client 75.24.105.18] PHP Fatal error: Cannot redeclare hassuspicioushackerstrings() (previously declared in /home/webadmin/comehike.com/html/connect.php:16) in /home/webadmin/comehike.com/html/connect.php on line 40 The error it is referring to is a function that is in the connect script. But if I remove the include '../connect.php'; Then it will just tell me that I can not use the mysql_real_escape_string function. So I am kind of stuck between not being able to use either option. php share|improve this question edited Dec 20 '12 at 18:49 hakre 133k26215386 asked Jun 10 '11 at 16:42 Genadinik 4,87042133227 You seem to be including the file that declares hassuspicioushackerstrings(). I don't think this has to do with mysql_real_escape_string() –Pekka 웃 Jun 10 '11 at 16:45 add a comment| 5 Answers 5 active oldest votes up vote 9 down vote accepted try include_once '../connect.php'; it'll make sure you're only including once this file share|improve this answer answered Jun 10 '11 at 16:44 afarazit 3,76712045 the include_once thing did the trick - thank you! –Genadinik Jun 10 '11 at 16:50 1 @Genadinik you should also read what @Fosco wrote about your error. Try to fix your error by redoing your program logic, include_
View Latest Posts or Search: Search Answered https://forums.modx.com/thread/98379/php-fatal-error-cannot-redeclare-function-previously-declared-in-a-snippet PHP Fatal error: Cannot redeclare function() (previously declared in a snippet Subscribe: RSS Login to Post 128 Posts Send PM Glyn Reply #1, 1 year ago I have written a snippet that contains a number of functions in it. When I place this snippet cannot redeclare multiple times within a template I get the following error: PHP Fatal error: Cannot redeclare displayMygif() (previously declared in ..modsnippet/25.include.cache.php:98) in ...modsnippet/25.include.cache.php on line 104 displayMygif() is a function I have created. How do I overcome this issue? Do I need to declare my cannot redeclare function functions some other way? Should I put all of my functions into a separate file and do a include_once on that. How do I do this within a snippet? Each time I call the snippet I use the following: [[!buildImage? &part=`toc` &layoutType=`[[*ImageLayout:getTVLabel]]` &imageNameStart=`is[[*IssueNumber]]-id[[*id]]-` &cog1=`[[*cog1]]` &cog2=`[[*cog2]]` &photo=`[[*photo]]` ]] cog1, cog2 and photo are image links. ImageLayout is a ToggleTVSet TV. This is all running within: I am using: MODX 2.40 Image + 2.3.4 pThumb 2.3.3 PHP 5.4.37 on a Apache server My snippet is as follows: //setup a few base variables $imagePath = 'images/icons/'; $exportPath = 'images/newsletter/'; $layout = $output = $thePart = $thelayoutType = $theImageName = $theCog1=$theCog2=$thePhoto=''; //lets get some snippet properties $thePart = $modx->getOption('part', $scriptProperties, '', true); $thelayoutType = $thePart.getLayoutName($modx->getOption('layoutType', $scriptProperties, '', true)); $theImageName = $modx->getOption('imageNameStart', $scriptProperties, '', true).$thelayoutType;