Namespaces?
4 posts
• Page 1 of 1
Namespaces?
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.
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?
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?
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.
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?
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.
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
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 27 guests