Jump to content

undefined function error.... but it is...


leijae

Recommended Posts

Happy 4th! I've done a lot of looking around searched the forums, and google... can't find a solution.

 

Error:

Fatal error: Call to undefined function getDirectory() in C:\xampp\htdocs\project\session_var.php on line 22

 

<?php
			if (isset($_SESSION['user']))
				{
					getDirectory('webs/sum2011');
					function getDirectory( $path = '.', $level = 0 )
						{
							$ignore = array( '.', '..' ); 
							$dh = @opendir( $path ); 
							$i = -2;

							while( false !== ( $file = readdir( $dh ) ) && ( $i < 5) ) 
								{ 
									$i++;
									if( !in_array( $file, $ignore ) )
										{ 
											if(is_dir( "$path/$file" ) )
												{ 	
													echo "<a href='$path/$file/index.php'>$file $i</a><br />";
													getDirectory( "$path/$file", ($level+1) );
												} 

										}
								}
							closedir( $dh ); 
						} 
				} else {
							getDirectoryFul('webs/sum2011');
							function getDirectoryFul( $path = '.', $level = 0 )
								{
									$ignore = array( '.', '..' ); 
									$dh = @opendir( $path ); 

									while( false !== ( $file = readdir( $dh ) ) ) 
										{ 
											if( !in_array( $file, $ignore ) )
												{ 
													if(is_dir( "$path/$file" ) )
														{ 	
															echo "<a href='$path/$file/index.php'>$file $i</a><br />";
															getDirectoryFul( "$path/$file", ($level+1) );
														} 

												}
										}
									closedir( $dh ); 
								} 
						}		
				?>

Link to comment
https://forums.phpfreaks.com/topic/241103-undefined-function-error-but-it-is/
Share on other sites

Functions need not be defined before they are referenced, except when a function is conditionally defined as shown in the two examples below.

 

When a function is defined in a conditional manner such as the two examples shown. Its definition must be processed prior to being called.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.