Referencing Previous Phalanger Variables Passed From C#

Phalanger Tools for Visual Studio [?] is complete PHP/Phalanger integration into Visual Studio development environment.

Referencing Previous Phalanger Variables Passed From C#

Postby MX26 » October 5th, 2014, 5:25 pm

Hi there,

I have a bit of code that runs like this in a C# class:
Code: Select all
dynamic response = PhalangerClass.GetResponse(variable);
dynamic testResult = PhalangerClass.TestResult(response);


GetResponse and TestResult are functions written in PHP and compiled using Pure Mode Phalanger.

The variables appear to pass successfully with one issue. Within PhalangerClass.TestResult, when I scope the $response variable, the variable consists of a binary component and a string component. I wish to reference the string component of the variable as the binary component is not compatible with the TestResult function.

Is there a way to accomplish this?

Thanks!
MX26
 
Posts: 18
Joined: May 14th, 2014, 4:49 pm

Re: Referencing Previous Phalanger Variables Passed From C#

Postby Jakub Misek » October 5th, 2014, 9:29 pm

What is the type of response variable?
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Referencing Previous Phalanger Variables Passed From C#

Postby MX26 » October 5th, 2014, 10:10 pm

Jakub,

The response variable is a string containing HTML from a web page response. The intention is to pass the string to the next Phalanger function for a parsing operation.
MX26
 
Posts: 18
Joined: May 14th, 2014, 4:49 pm

Re: Referencing Previous Phalanger Variables Passed From C#

Postby Jakub Misek » October 5th, 2014, 10:25 pm

If it is a string, it is passed in the same form into the next function. Try to put watch onto the C# variable response and look on its type.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakubjakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2092
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: Referencing Previous Phalanger Variables Passed From C#

Postby MX26 » November 5th, 2014, 1:44 am

Jakub,

Inspection of the variables within the PHP script reveals that they are an array. The first array index contains an array of binary. The second array index contains the string that I am looking for. The names of the array indices are 'Binary' and 'String', respectively. Attempting to pass the variable's [String] index to the main C# program only yields a variable containing bytes.

Thanks.
MX26
 
Posts: 18
Joined: May 14th, 2014, 4:49 pm

Re: Referencing Previous Phalanger Variables Passed From C#

Postby MX26 » November 5th, 2014, 1:49 am

Easy fix. I was able to simply convert the byte array within the C# calling program by using:

string result = System.Text.Encoding.UTF8.GetString(byteArray);

Another one for the records.
MX26
 
Posts: 18
Joined: May 14th, 2014, 4:49 pm


Return to Phalanger Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 151 on December 6th, 2020, 7:46 am

Users browsing this forum: No registered users and 1 guest