SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru arunkumar's Avatar
    Join Date
    Jan 2005
    Location
    India:Chennai
    Posts
    827
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a doubt in class in php

    Sir,
    I actually come across this coding

    <?php
    include "classes.class";

    $objP= new Page;
    $objP->disp( );
    ?>

    ;-)

    whether it is possiblt to include classes as .class file please explain me.

    ArunKumar
    Where there is a will there is a way
    ArunKumar

  2. #2
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It isn't required for an include file to have a .php file extension. However, just be aware that if it doesn't, anyone would be able to read the file.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  3. #3
    SitePoint Guru arunkumar's Avatar
    Join Date
    Jan 2005
    Location
    India:Chennai
    Posts
    827
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can i create a class file in php or it is a java class file.
    ArunKumar
    Where there is a will there is a way
    ArunKumar

  4. #4
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a very general format for creating a class in PHP.

    Code:
    <?php
    
    class ClassName
    {
    
    	var $var1;
    	var $var2;
    	...
    
    	//The constructor function
    	function ClassName(variable list here)
    	{
    	$this->var1 = $var1;
    	....
    	$this->ClassFunction();
    	}
    	
    	function ClassFunction()
    	{
    	//Do something here
    	}
    
    	function getClassVars()
    	{	
    	// Return variables to the calling function	
    	}
    }
    
    ?>
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  5. #5
    SitePoint Guru arunkumar's Avatar
    Join Date
    Jan 2005
    Location
    India:Chennai
    Posts
    827
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    after this is i have to save as .class extension? am i right
    ArunKumar
    Where there is a will there is a way
    ArunKumar

  6. #6
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Save your class with a .php file extension. That prevents being able to read the raw script.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •