我想将此函数转换为Php函数

private void CharsAvailable()
        {
            int num = 0;
            int num2 = 0;
            string text = this.txtMessage.Text;
            if (this.chkSignature.Checked)
            {
                text = text + Environment.NewLine + this.txtSignature.Text;
            }
            else
            {
                text = this.txtMessage.Text;
            }
            int num3 = 0;
            while (num != 1 && num3 < this.txtMessage.TextLength)
            {
                if (text[num3] < '0' || text[num3] > '9')
                {
                    if (text[num3] < 'A' || text[num3] > 'Z')
                    {
                    }  
                 ..............................
                   SOME CODE 
                 ............................

                if (num == 1)
                {
                    int num4 = text.Length;
                    if (num4 <= 70)
                    {
                        num4 = 1;
                    }
                    else
                    {
                        num4 += 62;
                        num4 -= num4 % 63;
                        num4 /= 63;
                    }
                    frmCompose.isUnicodeFound = true;
                    this.lblChar.Text = string.Concat(new object[]
                    {
                        text.Length,
                        " characters, ",
                        num4,
                        " SMS message(s)"
                    });
                }
                else
                {
                    int num4 = text.Length + num2;
                    if (num4 <= 160)
                    {
                        num4 = 1;
                    }
                    else
                    {
                        num4 += 152;
                        num4 -= num4 % 153;
                        num4 /= 153;
                    }
                    frmCompose.isUnicodeFound = false;
                    this.lblChar.Text = string.Concat(new object[]
                    {
                        text.Length + num2,
                        " characters, ",
                        num4,
                        " SMS message(s)"
                    });
                }
            }

            //validation

                        if (this.txtMessage.Text.Trim().Length == 0)
                        {
                            MessageBox.Show("Blank messages cannot send. Please type the message.", "Blank Message");
                        }
                        else if (frmCompose.isUnicodeFound && this.cmbLanguage.SelectedIndex == 0)
                        {
                            MessageBox.Show("Please choose 'Unicode' in Language dropdown to send message(s) in non English.”", "Unicode Message");
                        }enter code here

I want some help to convert this function in to the php function . what is the similar syntex or similar function in the relevant function in the php code . anybody can help with this . if i get some of the changes list need to make then it would be great .Thanks in advance .

First of all, i highly recommend to refactor your code before converting this to PHP. This is simply done by having two array and loop over them both whilest checking the characters. This will replace most of the statements.

A example ( in php ):

 $characters = array("{", "}", "\\", "[", "]", "~", "|", "€");
    $text = array();
    $num = 0;
    $num2 = 0;
    $num3 = 0;

    foreach($characters as $char)
    {
        if($text[$num3] == $char  ) 
        {
            $num2++;
        }else
        {
            $num = 1;
        }
    }

I've tried to keep the logic of the current code intact. Only implemented less obsolete/redundant.

Now this leaves us with the first 3 if statements. This is a perfect canidate for regex. Using preg_match in PHP you can easily replace those 3 if statements.

A PHP example:

    $text = "abcABC123";
    $regex = "/[a-zA-Z0-9]/";

    if(preg_match($regex, $text))
    {
        //Do stuff
    }

For the rest of the code is fairly straight forward and is mostly logic. One thing is for sure, please look into how to implements certain things more effeciently. It helps you and people who will work with the code in the future :)