I have a myfunctions.php file where I am listing all the require('function1.php') that I need. Its just a function file listing.
Im trying to use a function from http://pgregg.com/projects/php/ip_in_range/ that detects if an IP is in a range.
So I copied his function and putted it on a file that then I included in myfunctions.php.
Now, I just wanted to be sure there were no errors so I opened myfunctions.php and I have this error:
[text]Fatal error: Cannot redeclare float2largearray() (previously declared in /home/www/registrocr.com/editor/workspace/syscon/functions/bitwise_float.php:19) in /home/www/registrocr.com/editor/workspace/syscon/functions/bitwise_float.php on line 27[/text]
So I went to the file and I found that line 19 is where the function is declared and line 27 is where the ending } for that function is.
The same thing happens with any of the functions on the bitwise_float.php file.
I am not redeclaring anything, I can't understand why PHP says this.
Any help would be much appreciated.
As you can notice, Im just begining with php.
Why PHP says redeclare?
Moderator: General Moderators
Re: Why PHP says redeclare?
Check if your declared function page is including in the page during code running?
Re: Why PHP says redeclare?
gabrielpc1190 wrote:I have a myfunctions.php file where I am listing all the require('function1.php') that I need. Its just a function file listing.
Im trying to use a function from http://pgregg.com/projects/php/ip_in_range/ that detects if an IP is in a range.
So I copied his function and putted it on a file that then I included in myfunctions.php.
Now, I just wanted to be sure there were no errors so I opened myfunctions.php and I have this error:
[text]Fatal error: Cannot redeclare float2largearray() (previously declared in /home/www/registrocr.com/editor/workspace/syscon/functions/bitwise_float.php:19) in /home/www/registrocr.com/editor/workspace/syscon/functions/bitwise_float.php on line 27[/text]
So I went to the file and I found that line 19 is where the function is declared and line 27 is where the ending } for that function is.
The same thing happens with any of the functions on the bitwise_float.php file.
I am not redeclaring anything, I can't understand why PHP says this.
Any help would be much appreciated.
As you can notice, Im just begining with php.
Hi from what i can see is either the file you are using cannot see bitwise_float.php is it in the same folder? or that the files you have got from the site you show do not work in which case posting the files content will help us to see if it can be fixed
-
gabrielpc1190
- Forum Newbie
- Posts: 5
- Joined: Wed Oct 15, 2014 8:38 am
Re: Why PHP says redeclare?
This is the file http://pgregg.com/projects/php/ip_in_ra ... float.phps and the http://pgregg.com/projects/php/ip_in_ra ... range2.php
My myfunctions.php content is this:
My myfunctions.php content is this:
Code: Select all
<?php
include('bitwise_float.php');
include('ip_in_range2.php');
?>
Re: Why PHP says redeclare?
Your ip_in_range2.php file includes bitwise_float.php file, while you also include the latter file from your myfunctions.php file.
You may want to change your include statement to include_once (in both cases).
You may want to change your include statement to include_once (in both cases).
-
gabrielpc1190
- Forum Newbie
- Posts: 5
- Joined: Wed Oct 15, 2014 8:38 am
Re: Why PHP says redeclare?
You are right!
I didn't saw that!.
Removed the include line and everything is perfect.
Thanks!
I didn't saw that!.
Removed the include line and everything is perfect.
Thanks!