Namespaces?

Discussion about the open-source Phalanger [?] project.

Namespaces?

Postby evilmonkey@codeplex » September 8th, 2006, 12:58 am

Hello,

I am writing a backend in PHP and would like to integrate it with a visual basic fornt end. On a most basic level, I would like to generate a hello world in php and display it on a label in VB. So I wrote the following class in PHP:

codeclass output{
function __construct(){
return "Hello World"
}
}/code

And in VB:

codePrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim stuff = New PHP.User.output
Label1.Text = stuff.var.ToString()
End Sub/code

The problem is, I guess php.user.output displayed on the label instead of hello world. I'm guessing there is some kind of a typing problem. I'm not sure I understand how namespaces work in phlalnger. Please clarify. This is phalanger 1.0 on .NET framework 1.0 with Visual Studio 2003. Looking forward to a realse of Phalanger 2.0 with VS2005 integration. :)

Thanks.
evilmonkey@codeplex
 
Posts: 7
Joined: January 7th, 2012, 8:55 pm

RE: Namespaces?

Postby evilmonkey@codeplex » September 8th, 2006, 12:59 am

Sorry, last line of the VB code should say Stuff.toString, not stuff.var.toString.
evilmonkey@codeplex
 
Posts: 7
Joined: January 7th, 2012, 8:55 pm

RE: Namespaces?

Postby Lada Prosek » September 8th, 2006, 11:18 am

Hello,

the function named __construct is a constructor of the containing class and it does not make much sense returning anything from it.

The result of "New PHP.User.output" is a new instance of the output class. The __construct function is called as part of the instantiation but its return value is discarded.

Try adding another method that would return the result. Something like:

class output{

var $result;

function __construct() {
$this->result = "Hello World";
}

function getResult() {
return $this->result;
}
}

We already have VS integration available in our nighty builds and would be glad if you try it. Phalanger v2.0 (incl. the integration) uses completely separate directories, registry keys and so on so it will surely not break your existing v1.0 installation.
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: Namespaces?

Postby evilmonkey@codeplex » September 8th, 2006, 5:13 pm

Hello,

Thank you very much, that worked. I'm new at OOP, didn't realize constructor output would get discarded. Thanks for the help. =) I'll be sure to try your nightly builds.

Vitali.
evilmonkey@codeplex
 
Posts: 7
Joined: January 7th, 2012, 8:55 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 20 guests

cron

User Control Panel

Login

Who is online

In total there are 20 users online :: 0 registered, 0 hidden and 20 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 20 guests