×ðÁú¿­Ê±¹ÙÍøµÇ¼

ThinkPHPÖÐÔõÑùÉèÖýṹº¯Êý

Ò»¡¢Ê²Ã´Êǽṹº¯Êý

½á¹¹º¯ÊýÊÇÒ»¸öÔÚʵÀý»¯Ò»¸ö¹¤¾ßʱ×Ô¶¯Å²ÓõÄÌØÊ⺯Êý¡£ËüµÄ×÷ÓÃÊǶԹ¤¾ß¾ÙÐгõʼ»¯ £¬ÉèÖÃÊôÐԵijõʼֵµÈ¡£ÔÚPHPÖÐ £¬½á¹¹º¯ÊýµÄÃû³Æ±ØÐèΪ__construct()¡£

¶þ¡¢ÔÚThinkPHPÖÐÉèÖýṹº¯ÊýµÄ°ì·¨

Ê×ÏÈÎÒÃÇÐèÒª½¨ÉèÒ»¸öÀàÎļþ £¬ºÃ±È˵ÎÒÃÇ¿ÉÒÔ½¨ÉèÒ»¸öPHPÎļþ £¬ÃüÃûΪtest.php £¬´úÂëÈçÏ£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

<?php
namespace Home\Model;
use Think\Model;
class test extends Model{
    private $name;
    public function __construct($name){
        $this->name = $name;
    }
    public function get_name(){
        return $this->name;
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚtestÀàÄÚÀï £¬Ò»¸ö˽ÓÐÊôÐÔ $name ±»½ç˵ £¬Í¬Ê±ÉÐÓÐÒ»¸ö¹«¹²ÒªÁì get_name()¡£ÎÒÃÇʹÓÃ$name²ÎÊýÔڽṹº¯Êý__construct()ÖÐΪ$nameÊôÐÔ¸³³õÖµ¡£

ÔÚʹÓÃtestÀàµÄʱ¼ä £¬ÎÒÃÇ¿ÉÒÔÏñÏÂÃæÕâÑùʵÀý»¯¹¤¾ß£º

$t = new test("thinkphp");
echo $t->get_name();

µÇ¼ºó¸´ÖÆ

ÔÚʵÀý»¯¹¤¾ßµÄͬʱ £¬ÎÒÃÇת´ïÁËÒ»¸ö×Ö·û´®”thinkphp”×÷Ϊ²ÎÊý £¬Õâ¸ö²ÎÊý½«±»×ª´ï¸øÀàµÄ½á¹¹º¯Êý__construct() £¬²¢±»ÓÃÀ´ÉèÖÃÊôÐÔ$nameµÄ³õÖµ¡£×îÖÕ £¬ÎÒÃÇÓÃget_name()º¯ÊýÌáÈ¡$nameÊôÐÔµÄÖµ²¢¾ÙÐÐÊä³ö¡£

Èý¡¢Ê¹Óýṹº¯ÊýµÄÀûÒæ

ʹÓýṹº¯ÊýµÄÀûÒæÔÚÓÚ £¬¿ÉÒÔÔÚÀàʵÀý»¯µÄʱ¼ä¾ÍÍê³ÉһЩÐëÒªµÄ³õʼ»¯²Ù×÷ £¬×èÖ¹ÁËÔÚʹÓÃÀàµÄʱ¼ä»¹ÒªÐ´Ò»Ð©ÌØÁíÍâ³õʼ»¯´úÂë¡£ÕâÑù £¬Ê¹ÓÃÆðÀ´Ò²Ô½·¢Àû±ã¡£

ÒÔÉϾÍÊÇThinkPHPÖÐÔõÑùÉèÖýṹº¯ÊýµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ