View Single Post
  #3 (permalink)  
Old 10-18-2007, 08:08 AM
tj111 tj111 is offline
Novice
Join Date: Oct 2007
Posts: 2
iTrader: (0)
tj111 is on a distinguished road
I'm not sure exactly what your trying to do. I'm new here, so I'm not sure if my response is something your already very familiar with. PHP: Visibility - Manual

Even if the function is public, you still have to create the class before the function is created (the parser doesn't parse a class until it is created).
PHP Code:
$A = new A(); 
Once it's created, you can call the function:
PHP Code:
print "TEST: " $A->A1();
//Output == TEST A10 
The "+" is a mathematical operator, and since the string "TEST:" has no integral value, it evaluates to 0. Use "." instead for strings.

PHP Code:
print "TEST: " $A->A1();
//output == TEST A1TEST: 
Since the function prints an output, and the function call in a print statement, it won't work like expected.
PHP Code:
$A->A1();
//output == TEST A1 
So the whole script would be
PHP Code:
<?php
class {
    
public function A1() {
        print 
"TEST A1";
    }
    
    
public function A2() {
        print 
"TEST A2";
    }
};
$A = new A(); 
$A->A1();
//TEST A1
?>
Once again I don't know your level of knowledge with PHP, so if this is something your already familiar with, let me know.



__________________
PHP Code:
if (stristr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
    
$user 'noob';
    
session_destroy;
    
header("Location:http://firefox.com");


Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following 2 Users Say Thank You to tj111 For This Useful Post:
HelloWorld (10-18-2007), TeraTask (10-18-2007)