Jump to content

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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.