Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 131,784 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,897 people online right now. Registration is fast and FREE... Join Now!




class concepts

 
Reply to this topicStart new topic

class concepts

ajaycode
post 8 Oct, 2008 - 03:23 AM
Post #1


New D.I.C Head

*
Joined: 9 Aug, 2008
Posts: 40

QUOTE

i worte a code listing file and directories
but its showing syntax error
PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in E:\Playground\ncvsr\NCVSR_PROJECTS\NCVSM_ELAICHI\dev\version_1_0\web\elaichi\test\run.php on line 13


pls help me advance thanks

php

<?php

class clsFileExplorer Extends clsBase
{
// Public
public $cvar_aResult;
define("SYS_VAULT", "E:/Playground/NCVSR/NCVSR_PROJECTS/NCVSM_ELAICHI/dev/version_1_0");
define("SYS_ROOT",SYS_VAULT."/epnweb");
$_SESSION['SYSTEM_DIRECTORY_SEPARATOR']="/";

function ContentsOfDir($sDirpath)
{
if(strlen(trim($sDirpath)) == 0)
return false;

// get real path
$pge_sPath = realpath($sDirpath);

// create directory class
$pge_dirhandle = dir($pge_sPath);
$pge_nCount = 0;
$pge_aDirs=array();
$page_aFiles=array();

#check every item in the directory
while( false !== @($pge_item = $pge_dirhandle->read()) )
{
if( $pge_item != '.' AND $pge_item != '..' )
{
#check if dir or file
if( is_dir($pge_sPath.$_SESSION['SYSTEM_DIRECTORY_SEPARATOR'].$pge_item) )
{
$pge_aDirs[] = $pge_item;
}
elseif( is_file($pge_sPath.$_SESSION['SYSTEM_DIRECTORY_SEPARATOR'].$item) )
{
$pge_aFiles[] = $pge_item;
}
$pge_nCount++;
}
}
$pge_dirhandle->close();

#sort result
if( is_array($pge_aDirs) )
{
usort($pge_aDirs, 'strnatcmp');
}
if( is_array($pge_aFiles) )
{
usort($pge_aFiles, 'strnatcmp');
}
#create result array
$this->cvar_aResult['items'] = $pge_nCount;
$this->cvar_aResult['dirs'] = $pge_sDirs;
$this->cvar_aResult['files'] = $pge_sFiles;
return true;
}
}
$obj= new clsFileExplorer();
echo $obj->ContentsOfdir("e:/Databases");
?>

EDIT: code line numbers

This post has been edited by William_Wilson: 8 Oct, 2008 - 03:30 AM
User is offlineProfile CardPM

Go to the top of the page

pemcconnell
post 8 Oct, 2008 - 03:45 AM
Post #2


D.I.C Regular

Group Icon
Joined: 5 Aug, 2008
Posts: 392



Thanked 35 times

Dream Kudos: 75
My Contributions


is that the run.php file? Line 13 reads:

CODE

if(strlen(trim($sDirpath)) == 0)  
           return false;


which is fine?
User is offlineProfile CardPM

Go to the top of the page

ajaycode
post 8 Oct, 2008 - 04:07 AM
Post #3


New D.I.C Head

*
Joined: 9 Aug, 2008
Posts: 40

QUOTE(ajaycode @ 8 Oct, 2008 - 04:23 AM) *

QUOTE

i worte a code listing file and directories
but its showing syntax error
PHP Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION in E:\Playground\ncvsr\NCVSR_PROJECTS\NCVSM_ELAICHI\dev\version_1_0\web\elaichi\test\run.php on line 7



pls help me advance thanks

php

<?php

class clsFileExplorer Extends clsBase
{
// Public
public $cvar_aResult;
define("SYS_VAULT", "E:/Playground/NCVSR/NCVSR_PROJECTS/NCVSM_ELAICHI/dev/version_1_0");
define("SYS_ROOT",SYS_VAULT."/epnweb");
$_SESSION['SYSTEM_DIRECTORY_SEPARATOR']="/";

function ContentsOfDir($sDirpath)
{
if(strlen(trim($sDirpath)) == 0)
return false;

// get real path
$pge_sPath = realpath($sDirpath);

// create directory class
$pge_dirhandle = dir($pge_sPath);
$pge_nCount = 0;
$pge_aDirs=array();
$page_aFiles=array();

#check every item in the directory
while( false !== @($pge_item = $pge_dirhandle->read()) )
{
if( $pge_item != '.' AND $pge_item != '..' )
{
#check if dir or file
if( is_dir($pge_sPath.$_SESSION['SYSTEM_DIRECTORY_SEPARATOR'].$pge_item) )
{
$pge_aDirs[] = $pge_item;
}
elseif( is_file($pge_sPath.$_SESSION['SYSTEM_DIRECTORY_SEPARATOR'].$item) )
{
$pge_aFiles[] = $pge_item;
}
$pge_nCount++;
}
}
$pge_dirhandle->close();

#sort result
if( is_array($pge_aDirs) )
{
usort($pge_aDirs, 'strnatcmp');
}
if( is_array($pge_aFiles) )
{
usort($pge_aFiles, 'strnatcmp');
}
#create result array
$this->cvar_aResult['items'] = $pge_nCount;
$this->cvar_aResult['dirs'] = $pge_sDirs;
$this->cvar_aResult['files'] = $pge_sFiles;
return true;
}
}
$obj= new clsFileExplorer();
echo $obj->ContentsOfdir("e:/Databases");
?>

EDIT: code line numbers

error line no 7 thanks for response pls help me
User is offlineProfile CardPM

Go to the top of the page

pemcconnell
post 8 Oct, 2008 - 04:51 AM
Post #4


D.I.C Regular

Group Icon
Joined: 5 Aug, 2008
Posts: 392



Thanked 35 times

Dream Kudos: 75
My Contributions


move:

CODE

# define("SYS_VAULT", "E:/Playground/NCVSR/NCVSR_PROJECTS/NCVSM_ELAICHI/dev/version_1_0");  
define("SYS_ROOT",SYS_VAULT."/epnweb");  
$_SESSION['SYSTEM_DIRECTORY_SEPARATOR']="/";


to the top of your script (above class...)
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 03:05PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month