Results 1 to 11 of 11
Thread: Convert Php to C# ?
-
09-30-2004, 10:55 AM #1New Member
- Join Date
- Sep 2004
- Location
- Demorest, Ga
- Posts
- 2
Convert Php to C# ?
I need to convert Php to C# to add to an Asp page. How would I do this? Here is the code. Any help woul be greatly appreciated. Thanks,
if (isset($Submit)==false) $Submit="";
if (isset($Name)==false) $Name="";
if (isset($Company)==false) $Company="";
if (isset($EMail)==false) $EMail="";
if (isset($Phone)==false) $Phone="";
if (isset($Fax)==false) $Fax="";
if (isset($Questions)==false) $Questions="";
if (isset($ClassName)==false) $ClassName="";
if (isset($ContactName)==false) $ContactName="";
if (isset($ContactCompany)==false) $ContactCompany="";
if (isset($ContactEMail)==false) $ContactEMail="";
if (isset($ContactPhone)==false) $ContactPhone="";
if (isset($ContactFax)==false) $ContactFax="";
if ($Submit==""||$Name==""||$Company==""||$EMail==""||$Phone==""||$Fax=="")
{
if ($Name !="") $ContactName =$Name;
if ($Company!="") $ContactCompany=$Company;
if ($EMail !="") $ContactEMail =$EMail;
if ($Phone !="") $ContactPhone =$Phone;
if ($Fax !="") $ContactFax =$Fax;
-
10-09-2004, 06:10 PM #2Junior Guru Wannabe
- Join Date
- Oct 2004
- Location
- Canada
- Posts
- 76
Re: Convert Php to C# ?
Originally posted by kf4mms
I need to convert Php to C# to add to an Asp page. How would I do this? Here is the code. Any help woul be greatly appreciated. Thanks,
if (isset($Submit)==false) $Submit="";
if (isset($Name)==false) $Name="";
if (isset($Company)==false) $Company="";
if (isset($EMail)==false) $EMail="";
if (isset($Phone)==false) $Phone="";
if (isset($Fax)==false) $Fax="";
if (isset($Questions)==false) $Questions="";
if (isset($ClassName)==false) $ClassName="";
if (isset($ContactName)==false) $ContactName="";
if (isset($ContactCompany)==false) $ContactCompany="";
if (isset($ContactEMail)==false) $ContactEMail="";
if (isset($ContactPhone)==false) $ContactPhone="";
if (isset($ContactFax)==false) $ContactFax="";
if ($Submit==""||$Name==""||$Company==""||$EMail==""||$Phone==""||$Fax=="")
{
if ($Name !="") $ContactName =$Name;
if ($Company!="") $ContactCompany=$Company;
if ($EMail !="") $ContactEMail =$EMail;
if ($Phone !="") $ContactPhone =$Phone;
if ($Fax !="") $ContactFax =$Fax;
something like this
if (isset($Submit)==false) $Submit="";
I am assuming that isset is a method and $Submit a string variable.
you would have something like this in C#
if (isset(Submit) == false)
{
Submit = "";
}
I don't think the C# compiler would like a variable name starting with $.
Bear in mind that C# is strongly typed, so the variables types and return types of methods have to be carefully defined.
is isset a PHP functions? what does it do?
-
10-12-2004, 10:12 PM #3New Member
- Join Date
- Sep 2004
- Location
- Demorest, Ga
- Posts
- 2
Re:
Sorry it took me awhile to get back to you. This php code was used on our company website to check forms containing name, address and so forth. If any of these fields were blank, you couldn't submit until it the form was completed. Thank you very much for the reply. That gets me pointing in the right direction.
-John
-
10-17-2004, 10:25 PM #4Junior Guru Wannabe
- Join Date
- Oct 2004
- Location
- Canada
- Posts
- 76
Re: Re:
Originally posted by kf4mms
Sorry it took me awhile to get back to you. This php code was used on our company website to check forms containing name, address and so forth. If any of these fields were blank, you couldn't submit until it the form was completed. Thank you very much for the reply. That gets me pointing in the right direction.
-John
-
06-29-2005, 09:52 AM #5Newbie
- Join Date
- Jun 2005
- Posts
- 8
here is a quick isset method ( in c# ) if you want, although I am sure you dont by now....
private bool isSet(object o)
{
// check if the object is null
if (o == null )
return false;
else
return true;
}
-
07-11-2005, 04:39 AM #6Junior Guru
- Join Date
- Mar 2005
- Posts
- 214
right i just got a c# compiler and i want to know what are good sites for learning c# and how can you put c# programs in to webpages? if its possible? or only .exes allowed to be made?
-
07-11-2005, 11:34 AM #7Newbie
- Join Date
- Jun 2005
- Posts
- 8
You can not ( well you can but its not the best way to handle it ) put EXE's in your website, however you can have DLL's in your website....
http://www.asp.net is a good place to start looking for tutorials, or google "C# ASP.NET Tutorials" or something to that nature!
ALso, for DLL imports, search for importing / using DLL's in your ASP.NET application.
Good luck
Post if you need a hand.....
-
07-27-2005, 05:14 PM #8Junior Guru Wannabe
- Join Date
- Oct 2004
- Location
- Canada
- Posts
- 76
Originally posted by maddudemike
right i just got a c# compiler and i want to know what are good sites for learning c# and how can you put c# programs in to webpages? if its possible? or only .exes allowed to be made?
However, keep in mind that a new version of .net (2.0) is going to be released in November.
In C# the differences are not many, but important (such as generics or iterators), you can still start learning because those topics are advanced stuff.
Regarding putting C# on a web page, well, it is a complex question, the answer is yes but...
Basically, you can have different situations:
1) you are running a web application. This has to be done through an ASP.net application, which only runs on IIS (that means, Windows). Basically, an asp.net page has an aspx extension, and normally the so called "code behind", that is the code that drives the page (similar to scripts in php or asp), the difference is that it's compiled in to .dll that it's then executed on the server to render the page.
2) you can have class libraries written in C#, they will be .dll, they can have some functionality for your application (for example in the so called multi-tier applications) and they will be called from the .dll mentioned above (this is a simplification).
3) I guess you could run a .dll in the cgi-bin, but I don't think anybody would do that now, still, you need the .net framework installed.
4) you can indeed have an .exe on a web server and run it on a local machine, this is tricky though. It won't run on the server, it will actually download the file and run it on your local machine but, you need to have appropriate security policies in your machine, otherwise the OS won't run the code. Basically you need to have the website in your list of trusted sites to run code from, and you have to specify what that code can do. Not a very common scenario, it's theoretically possible but I don't see any use for it and it's dangerous, especially since with the new version of the framework, they implemented something called "click once" that allow you to deploy desktop application through the web (meaning, you download an installer).
-
07-28-2005, 11:24 PM #9WHT Addict
- Join Date
- Jan 2005
- Posts
- 131
as SuperSac said you gona use bool and a fuction ,for example(hope thats what you mean) :
if (fuction()==true)
{
cout << "submit= " << submit ;
else {
return;
}
}
bool function(object submit)
{
if (submit == null )
return false;
else
return true;
}
-
07-29-2005, 05:19 AM #10Disabled
- Join Date
- Jun 2004
- Posts
- 17
Re: Re: Convert Php to C# ?
Originally posted by Ricardob
hmmm, I am pretty good with C# but pretty bad with PHP, If I understdood better what this is trying to do I could help
something like this
if (isset($Submit)==false) $Submit="";
I am assuming that isset is a method and $Submit a string variable.
you would have something like this in C#
if (isset(Submit) == false)
{
Submit = "";
}
I don't think the C# compiler would like a variable name starting with $.
Bear in mind that C# is strongly typed, so the variables types and return types of methods have to be carefully defined.
is isset a PHP functions? what does it do?
basically what it does is checks if the variable isnt blank or unset
-
07-30-2005, 07:38 PM #11Newbie
- Join Date
- Jul 2005
- Posts
- 7
I would guess that you could use the HttpRequest object to check for the set status on the parameters that you are checking for using isset.