Home  >  Article  >  Backend Development  >  PHP member variable assignment uses connector to report error

PHP member variable assignment uses connector to report error

WBOY
WBOYOriginal
2016-07-29 09:14:141114browse

I encountered a problem today. When assigning a value to a member variable in a class, I kept getting an error. It is a constant connected to a string

<code><span><span>class</span><span>FileUploadController</span><span>extends</span><span>Controller</span>{</span><span>private</span><span>$path</span> = BASEDIR.<span>"/Public/Upload"</span>;           <span>//<strong>上传文件</strong>保存你路径</span><span>private</span><span>$allowType</span> = <span>array</span>(<span>'jpg'</span>,<span>'png'</span>,<span>'gif'</span>);          <span>//文件限制格式</span></code>

If the original member variable contains a constant or variable, and the connected string must assign a value to the member variable through the construction method, otherwise the constant will not be visible in the class

<code><span>public</span><span><span>function</span><span>__construct</span><span>()</span>{</span><span>$this</span>->path = <span>__DIR__</span>.<span>"/Public/Upload"</span>;
    }</code>

If it only contains constants, there is no need to construct it Method

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the error reporting using connectors for PHP member variable assignment, including the content of uploading files. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn