ကုလားအုတ်ကော်ဇာသည်နာမည်နိဗ္ဗာန်ကိုပထမစကားလုံးဖြင့်စတင်ပြီးစာလုံးအသေးဖြင့်စတင်သည်, ဒုတိယစကားလုံးဖြင့်စတင်ခြင်းသည်စာလုံးတစ်လုံးစီတွင်စာလုံးတစ်လုံးစီရှိသည်။ Naming Method သည် camelcape ။
PHP တွင် variable name တွင်အလျားလိုက်မျဉ်းကြောင်းတစ်ခုပါ 0 င်ပါက, ဥပမာအားဖြင့်:
$stu_id = $student->{'stu-id'};
အကယ်. သင်သည်အလျားလိုက်အလျားလိုက်မျဉ်းကိုကုလားအုတ်ကို camel nomenclature သို့ပြောင်းလဲလျှင် attribute ကိုရယူရန် Dot နံပါတ်ကိုတိုက်ရိုက်သုံးနိုင်သည်။
$stu_id = $student->stuId;
၎င်းသည်ကုဒ်ကိုပိုမိုရိုးရှင်းလွယ်ကူစေသည်။ ဖတ်ရန်လွယ်ကူစေသည်။
ပုံမှန်အသုံးအနှုန်းများမှတစ်ဆင့်ကုလားအုတ်ကို Nomenclature မှအလျားလိုက်မျဉ်းကြောင်းကိုအကောင်အထည်ဖော်ရန် `preg_replace` function ကိုသုံးပါ။ ဒီမှာဥပမာတစ်ခုပါ။
$str = 'student-name';
$str = preg_replace_callback('/-(\w)/', function($matches) {
return strtoupper($matches[1]);
}, $str);
echo $str; // ထုတ်လုပ်ခြင်း studentName
ဤကုဒ်သည်စာလုံးရေတိုတောင်းသောအလျားလိုက်မျဉ်းကြောင်းအပြီးစာလုံးအကြီးအမြင့်ဆုံးလိုင်းကို `preg_replace_callback`. function ကိုဖြတ်ပြီး camel nomenclature ကိုသဘောပေါက်သည်။
နောက်နည်းတစ်နည်းမှာ `strow_replace` function ကိုသုံးရန်ဖြစ်သည်, ပထမ ဦး ဆုံးအတိုအလျားလိုက်မျဉ်းကြောင်းကိုနေရာများနှင့်အစားထိုးရန်, စကားလုံးတစ်လုံးစီ၏ပထမအက်ခရာကိုစာလုံးအကြီးအပါစေပြီးနောက်ဆုံးတွင်နေရာများကိုဖယ်ရှားပါ။ Code pegager ်ဌာန်းချက်မှာအောက်ပါအတိုင်းဖြစ်သည် -
$str = 'student-name';
$str = str_replace('-', ' ', $str);
$str = ucwords($str);
$str = str_replace(' ', '', $str);
echo $str; // ထုတ်လုပ်ခြင်း studentName
ဤကုဒ်သည်အလျားလိုက်အလျားလိုက်မျဉ်းကြောင်းကိုနေရာတစ်ခုနှင့်အတူပထမနေရာတွင်အစားထိုးသည်။ ထို့နောက် `ucwords` function ကိုအသုံးပြုသည်။
SymFony ၏ string အစိတ်အပိုင်းသည် `` `` `` `` `` hearnontal လိုင်းများကိုကုလားအုတ်ကို Nomenclature သို့အလွယ်တကူပြောင်းလဲနိုင်သည်။ ဥပမာများမှာအောက်ပါအတိုင်းဖြစ်သည် -
use Symfony\Component\String\Inflector\EnglishInflector;
$inflector = new EnglishInflector();
$str = 'student-name';
$str = $inflector->camelize($str);
echo $str; // ထုတ်လုပ်ခြင်း studentName
ဤကုဒ်တွင် `EnglfulnFony \ component \ string \ hearinflector` `` citterize` ကို အသုံးပြု. ပြောင်းလဲခြင်းအတွက် `citterize` method ကိုအသုံးပြုပါ။
PHP တွင်အတိုချုပ်အလျားလိုက်လိုင်းများကို `preg_replace`` strip_replace` `stred'tloplate` `symfony string on` commfony string on `commfony string on` commfony string components` နှင့် `symfony strings` `cymfony string components` ။ အမှန်တကယ်လိုအပ်ချက်များပေါ် မူတည်. သင်၏ကုဒ်၏ဖတ်ရလွယ်ကူခြင်းနှင့်ထိန်းသိမ်းခြင်းကိုပိုမိုကောင်းမွန်စေရန်အသင့်တော်ဆုံးနည်းလမ်းကိုရွေးချယ်နိုင်သည်။