I teach PHP (a)

Source: Internet
Author: User
The company came to a newcomer, claiming to have written 8 months PHP, and then will write Mysql_connect, will not write loops, do not understand the two-dimensional array. The foundation is bad, let me want to hit death.

Oh, teach it, see if you can teach it.

-----------------------------------------------------------
There are 3 main variables of PHP. String, array, object
How to use them.

-----------------------------------------------------------
for string
$string = "string"
-----------------------------------------------------------
Build a test.php, test the following example to see what the output is different from, what's the same

$str = "I am a string";
Echo $str;
$str 2 = "He is an array, I am the string 2";
echo $str 2;


-----------------------------------------------------------
For array
$arr = Array (' key ' = ' value ');
-----------------------------------------------------------
Build a test.php, test the following example to see what the output is different from, what's the same

$arr = Array (' name ' = ' Zhang San ', ' php ' = ' beginner ');
Print_r ($arr)

$arr 2[' name '] = ' Zhang San ';
$arr 2[' php '] = ' beginner ';
$arr 2[' info '] = ' html proficiency ';
Print_r ($arr 2)


-----------------------------------------------------------
For object
$ob = new StdClass;
$ob->key = value;
-----------------------------------------------------------
Build a test.php, test the following example to see what the output is different from, what's the same

$ob = new StdClass;
$ob->name = ' Zhang San ';
$ob->php = ' beginner ';
Print_r ($OB)

$ob 2 = new StdClass;
$ob 2->name = ' Zhang San ';
$ob 2->php = ' beginner ';
$ob 2->info = ' also good ';
Print_r ($ob 2)

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.