The change after PHP programmer learns objective-c

Source: Internet
Author: User
Tags learn php

Fun to talk about, not necessarily 100% accurate, the actual situation of their own prevail;

Title, I began to learn php,php in 2008, I learned the second programming language, has been used to now, in early 2010 began to do iOS development, learning Objective-c, learn the 2 languages between the 2-year interval;

Recently turned to 2008-2010 years between their own written PHP code, combined with the current project coding style, summed up the changes as follows:;

1. Now like to use a long and smelly class name, method name, parameter name, as long as the writing is not long enough, how to find ways to add to a very long, so now write PHP is very dependent on can automatically complete the IDE (by Xcode spoiled), because it is really long;

Previously, using PHP to write a method is this;

1 function checkpass ($name,$pass) {2   //...   3 }

Now it's written like this;

1 class Usermodel {2      Public function checkifpasswordisrightwithusername ($username, $password) {3         // ... 4     }5 }

2. Only like to use the Hump method, do not like to use _;

Used to write like this;

1 $user _token $user _model->get_user_access_token ();

Now write this;

1 $userAccessToken $userModel:: getinstance ()->getusertokenforaccessatmasterdatabasewithcache ($cacheConfigure);

3. Before you start the project, define a bunch of smelly and long-used constants (with OC);

The following extracts part of an item;

1<?PHP2 /**3 * Global Configuration macros
* @author: Legend_yin<[email protected]>4 */5 6 //Debugging related Configurations7 Define("App_http_parameter_sign_check",true);8 Define("App_parameter_time_check",false);9 Define("App_parameter_request_id_check",true);Ten One Define("Memcache_key_prefix_access_token_key", "Access_token_key_");Define(' memcache_key_prefix_system_settings ', ' System_settings_ '); A - Define("Memcache_key_lifetime_access_token_key", 7200); - Define(' Memcache_key_lifetime_system_settings ', 3600*12); the - Define(' Common_parameter_user_token ', ' User_token '); - Define(' Common_parameter_time ', ' time '); - Define(' Common_parameter_version ', ' VERSION '); + Define(' common_parameter_request_id ', ' request_id ');

4. Like to pack PHP __construct into $SOMEOBJ->alloc ()->init ();

5. The array in PHP is not consciously divided into 2 types;

As follows

1 <? PHP 2 3 $userArray Array ("Tom", "Jerry", "Jack"); 4 5 $userDictionary Array ("First" = "Tom", "Second" = "Jerry", "third" and "Jack");

6. Write so much first, and think of adding

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.