Martes, Oktubre 4, 2011

assignment in WEB programming

Variables are declared when first used in PHP, so no need for the following...

var $somevar;

In PHP, this is only neccessary when building a class, the var keyword when used inside of a class creates special class-scope static variables.

$myvar = "some value";
Automatically created as a String.

$myvar = 2;
Automatically created as an integer.

$myvar = (string) "Some text";
Typecast as a string explicitly (typecasting is optional in PHP for 99% of variable usages).

$myvar = (int) 45;
Typecast an integer.

When you compare values as in...
if($myvar == "some value")

If myvar does not exist PHP will temporarily create a copy of it in memory with null value for comparision purposes, if error_reporting is set to E_ALL PHP will issue a Notice level error complaining that the variable did not exist. A better method is to use isset() or empty()

if (isset($myvar) && $myvar == "some_value)

http://www.php.net/isset
http://www.php.net/empty

This alleviates that Notice level error.

Always best to read the manual... at
http://www.php.net/manual/en/

Pay special attention to section II, which contains basic syntax, control structures, predefined variables... and general language concepts implemented in PHP.

hth,
: )
Rich









2.)



Naming Rules

Given below key naming conventions of PHP variable :
  • A variable must have $ sign before its actual name. Example, $first_name.
  • A variable in PHP must start with a letter or underscore "_".
  • A variable in PHP can have only numeric(0-9), letter(a-z, A-Z) or underscore"_".
  • PHP variables are case sensitive. The variables $c_number and $C_number are different variables in PHP.
  • The variable name must not have white spaces between them. You can use underscore "_" to fill them. For example, it shouldn't like this-$first name, it should be-$first_name.
No need of declaring data type in PHP
A PHP variable doesn't need to be declare before before adding a value to it. PHP automatically converts the variable to the correct data type, depending on its value.
In the given below example, you will see that there is no need of mentioning data type before passing value to it.






visual
code in login form


Dim orow As DataRow
        For Each orow In Me.ProfileDataSet1.USER
            If (orow.Item("username") = Me.TextBox1.Text) Then
                If (orow.Item("password") = Me.TextBox2.Text) Then
                    MsgBox("you may now to proceed")

                    Form1.ShowDialog()

                Else : MsgBox("USERNAME / PASSWORD")
                End If
                Me.Close()


            End If


        Next
    End Sub




form code




Public Class Form1
    Private Sub enabledcontrol()

        Me.LASTNAMETextBox.Enabled = True
        Me.FIRSTNAMETextBox.Enabled = True
        Me.MITextBox.Enabled = True
        Me.AGETextBox.Enabled = True
        Me.COURSETextBox.Enabled = True
        Me.SECTIONTextBox.Enabled = True
        Me.ADDRESSTextBox.Enabled = True
        Me.EMAILADDTextBox.Enabled = True
        Me.NATIONALITYTextBox.Enabled = True
        Me.BIRTHPLACETextBox.Enabled = True
        Me.BIRTHDATEDateTimePicker.Enabled = True
        Me.GUARDIANTextBox.Enabled = True


    End Sub

    Private Sub disabledcontrol()

        Me.LASTNAMETextBox.Enabled = False
        Me.FIRSTNAMETextBox.Enabled = False
        Me.MITextBox.Enabled = False
        Me.AGETextBox.Enabled = False
        Me.COURSETextBox.Enabled = False
        Me.SECTIONTextBox.Enabled = False
        Me.ADDRESSTextBox.Enabled = False
        Me.EMAILADDTextBox.Enabled = False
        Me.NATIONALITYTextBox.Enabled = False
        Me.BIRTHPLACETextBox.Enabled = False
        Me.BIRTHDATEDateTimePicker.Enabled = False
        Me.GUARDIANTextBox.Enabled = False


    End Sub



Walang komento:

Mag-post ng isang Komento