Home  >  Article  >  Backend Development  >  PHP Job Search Guide Series - PHP Web Programming

PHP Job Search Guide Series - PHP Web Programming

WBOY
WBOYOriginal
2016-08-08 09:22:311572browse

PHP Web Programming

form form

  1. Briefly describe the maximum capacity of POST and GET transmission?


  • single data quilt Appended to the URL and sent to the server as part of the URL. URL length should be limited to 1MB characters.
  • The POST method does not rely on URL and does not display the passed parameter value in the address bar. In addition, the POST method can transfer data to the server without any restrictions. All submitted information is transmitted in the background and cannot be seen by the user on the browser side, which is highly secure.

2. How to control the size of uploaded files through the form?

  • enctype="multipart/form-data", specifies the way to encode data in the form.
  • method="post", specifies the data transmission method.
  • , Control the size of the uploaded file (in bytes) through the hidden field, the value Cannot exceed the value set by the php.ini configuration file upload_max_filesize option.

3. How to set the read-only attribute in the form?

  • uses readonly to set the read-only attribute of the specified content;
  • uses disabled to set the read-only attribute of the specified content.

  4. Under what circumstances can $name and $_POST['name'] be used interchangeably?

When register_globals = On in the php.ini file, both $name and $_POST['name'] can get the value of the form element name in the form form (submitted in post mode).

But it is not recommended to turn on all the register_globals variables because it will bring security risks to the program.


CSS Styles

1.What is the meaning of CSS?

CSS (Cascading Style Sheet, translated as "Cascading Style Sheet" or "Cascading Style Sheet") language is a markup language that does not require interpretation and can be directly used by the browser Interpretation and execution (belongs to browser interpreted language) to control the appearance of Web pages. It is a set of extended style standards specified by the W3C Association to make up for the shortcomings of HTML in setting display attributes.

Its functions are as follows:

  • In standard web design, CSS is responsible for the performance of web content (XHTML).
  • A CSS file can also be said to be a text file, which contains some CSS tags. The CSS file must use the .css suffix.
  • Separation of content and presentation through CSS files can change the overall presentation of the web page, making it easier to maintain the appearance of the site, making the HTML document code more concise, and shortening the browser loading time .

  2. How many ways to insert CSS styles into HTML pages?

  • Define a pair of tags under the tag in the HTML page, and use the tag name and class inside the tag Selector and id selector set attributes.
  • Define the style attribute inside the tag, and then define the style under this tag, such as:

Link Use the tag to import files. Such as:

3. Commonly used attributes of CSS styles:

Commonly used attributes of CSS styles
Attribute name parsing
border define the properties of the border to set the width, color, and style of the border
background-color Set the background color
background-image Set the background image
font-size Set the font size
font-family Set the font
text-decoration Retrieve or set the decoration of the text in the object , such as underlining, blinking, etc.
line-height Retrieve or set the line height of the object, that is, the distance between the bottom of the font and the top of the font inside
letter-spacing Retrieve or set the object The spacing between text
text-align Sets or retrieves the alignment of text in an object


4. How to solve the problem of the following code under IE6 Double margin issue?

<span><span><style type="text/css">
body </span>{<span>margin</span>:<span>0</span>;}<span>div  </span>{<span>float</span>:<span>left</span>;  <span>margin-left</span>:<span>10px</span>;<span>    width</span>:<span>200px</span>;<span>    height</span>:<span>200px</span>;  <span>border</span>:<span>1px</span>;<span>    solid red;</span>}<span></style></span></span>

 This is a common bug under IE6. Although the defined margin is 10px, IE parses it as 20px.

Solution: Add the attribute display:inline

5. How to solve the problem that the hover style does not appear after the hyperlink is clicked?

Just sort the hyperlink style attributes correctly.

a:link{color:red;text-docoration:none}

a:visited{color:blue;text-decoration:none}

a:hover{color:black;text-decoration:overline}

a:action{color:black;text-decoration:overline}

6. How to solve the problem under Firefox browser Text cannot expand the height of the container?

Add two CSS properties, min-width and min-height. You can also add a div with a clear:both attribute to clear the alignment to automatically calculate the height of the Firefox browser. .

7. How to define a container with a height of about 1px?

In the process of web page layout, a partition is often needed between the navigation bar and the content bar. Generally, setting a height of 1 pixel is optimal.


DIV tag

1. The difference between tags and

:

 

and Tags also work in web page layout. The difference between them is:

  • span tags are inline and are generally used to inline the styles of small modules into HTML documents
  • div elements themselves are blocks level element, mostly used to combine large blocks of code

2. How to center a DIV layer?

position:absolute;

top:50%;

left:50%;

margin: -100 px 0 0 -100px;

3. How to solve the problem of invalid text-align attribute of nested div tags in filefox browser?

<span>1</span><span><style>
</span><span>2</span><span>.one </span>{<span>border</span>:<span>1px solid blue</span>;<span>width</span>:<span>300px</span>;<span>height</span>:<span>200px</span>;<span>text-align</span>:<span>center </span>}
<span>3</span><span>.two </span>{<span>border</span>:<span>1 px solid blue</span>;<span>width</span>:<span>200px</span>;<span>height</span>:<span>100px</span>;<span>margin</span>:<span>0px auto </span>}
<span>4</span><span></style>
</span><span>5</span><span><div>
</span><span>6</span><span><div></div>
</span><span>7</span><span></div></span>

JavaScript script

1. The function of popping up the dialog box and the function of getting the input focus:

Use the alert() function to pop up a dialog box

Use the focus() function to get input focus

2. What is the redirect function of JavaScript? How to import an external JavaScript file?

  Steering function: window.location.href="File name";

  Introducing external JavaScript files:

3. When the mouse passes over the text box, the content in the text box is automatically selected:

5. JavaScript code to set the homepage:

Ajax application
1. Use Ajax in jQuery to determine whether the user name is occupied:

Need to define two pages , index.php page code is as follows:

 1 <script type="text/javascript" src="jquery-1.4.2.js"></script>
 2 <input type="text" ><input type="button" value="校验">
 3 <script type="text/javascript">
 4 $(<span>function</span><span>() {
 </span>5       $("input:last".click(<span>function</span><span>() {
 </span>6             $.get ("in.php",<span> {
 </span>7                     username:$("input:first").<span>val()
 </span>8             },<span>function</span><span>(data) {
 </span>9<span>                     alert (data);
 </span>10             })'<span> 11        });
 12 });
 13 </script></span>  in.php page code is as follows: <pre class="brush:php;toolbar:false"><span> 1</span> <?<span>php
</span><span> 2</span><span>$string</span>="明日科技"<span>;
</span><span> 3</span><span>if</span>(<span>isset</span><span>($ GET[username])) {
</span><span> 4</span><span>if</span>(<span>urldecode</span>($ GET[username])==<span>$string</span><span>) {
</span><span> 5</span><span>echo</span> "用户名被占用"<span>;
</span><span> 6</span>     }<span>else</span><span>{
</span><span> 7</span><span>echo</span> "用户名可用"<span>;
</span><span> 8</span><span>    }
</span><span> 9</span><span>}
</span><span>10</span> ?>

2. Write code to enter a year in the text box and judge Its zodiac sign, and output next to the text box, requires writing HTML and JavaScript code:


The code for the front page design is as follows:

<span> 1</span><span><</span><span>html</span><span>></span><span> 2</span><span><</span><span>head</span><span>></span><span> 3</span><span><</span><span>meta </span><span>http-equiv</span><span>="Content-type"</span><span> content</span><span>="text/html;charset="</span><span>UTF-8""</span><span>></span><span> 4</span><span><</span><span>script </span><span>type</span><span>="text/javascript"</span><span> src</span><span>="jequery-1.4.2.js"</span><span>></</span><span>script</span><span>></span><span> 5</span><span><</span><span>title</span><span>></span>生肖的自动选择<span></</span><span>title</span><span>></span><span> 6</span><span></</span><span>head</span><span>></span><span> 7</span><span><</span><span>body</span><span>></span><span> 8</span><span><</span><span>input </span><span>type</span><span>="text"</span><span> value</span><span>="请输入年份格式为2015"</span><span> onclick</span><span>="this.select()"</span><span>></span><span> 9</span><span><</span><span>input </span><span>type</span><span>="submit"</span><span> value</span><span>="判断"</span><span>></span><span>10</span><span><</span><span>span</span><span>></</span><span>span</span><span>></span><span>11</span><span><</span><span>script</span><span>></span><span>12</span><span>    $(</span><span>function</span><span>(){
</span><span>13</span><span>        $(</span><span>"</span><span>input:last</span><span>"</span><span>).click(</span><span>function</span><span>(){
</span><span>14</span><span>            $.get(</span><span>"</span><span>in.php</span><span>"</span><span>,{
</span><span>15</span><span>                number:$(</span><span>"</span><span>input:first</span><span>"</span><span>).val()
</span><span>16</span><span>            },</span><span>function</span><span>(data){
</span><span>17</span><span>                    $(</span><span>"</span><span>span</span><span>"</span><span>).text(data);
</span><span>18</span><span>            });
</span><span>19</span><span>        });
</span><span>20</span><span>});
</span><span>21</span><span></</span><span>script</span><span>></span><span>22</span><span></</span><span>body</span><span>></span><span>23</span><span></</span><span>html</span><span>></span>

View Code
  PHP script to determine the zodiac sign in the background:

<span>1</span> <?<span>php
</span><span>2</span><span>if</span>(<span>isset</span>(<span>$_GET</span>[<span>number</span><span>])){
</span><span>3</span><span>$array</span>=<span>array</span>("猪","鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗"<span>);
</span><span>4</span><span>foreach</span>(<span>$array</span><span>as</span><span>$key</span>=><span>$value</span><span>) {
</span><span>5</span><span>if</span>(<span>ceil</span>(<span>$_GET</span>[<span>number</span>]%12)==<span>$key</span><span>){
</span><span>6</span><span>echo</span><span>$value</span><span>;
</span><span>7</span><span>                 }
</span><span>8</span><span>        }
</span><span>9</span> }

jQuery framework

  目前比较流行的客户端脚本语言框架jQuery,由美国人John Resig创建,是优秀的JavaScript框架,其宗旨是write less,do more.它是轻量级的js库,兼容CSS3,兼容各种浏览器(IE 6.0+)。用户能更方便地处理HTML document、events,实现动画效果,并且可以方便地为网站提供AJAX交互。jQuery另一个比较大的优势是,它的文档说明很全,而且各种应用也说的很详细,同时还有许多成熟的插件可供选择。jQuery能够使用户的HTML页保持代码和HTML内容的分离,也就是说,不用再在HTML里面插入一堆js来调用命令了,只需定义id即可。

1.jQuery中常用选择器:

基本选择器:

  id选择器:只能用一次

  class选择器:允许重复使用

  标签选择器

  *:匹配所有元素

层次选择器:

  $("#a.b") 选取id值为a的元素里所有class值为b的元素。

  $("#a>.b") 选取id值为a的元素后的class值为b的子元素。

  $("#a+.b") 选取id值为a的元素后紧挨的class值为b的元素。

过滤选择器:

  :first,选取第一个元素。

  :odd,选取索引是奇数的元素。

  :even,选取索引是偶数的元素。

  :not,选取除某元素外的其他元素。

  :eq(),按索引寻找元素。

  :lt(),小于某索引值的元素。

  :gt,大于某索引值的元素。

2.如何实现查找DOM树中的元素?

var input = $("input:first");

 3.如何在DOM树中创建并插入元素?

<span>1</span> <script type="text/javascript" src="jquery-1.4.2.js"></script>
<span>2</span> <div>水果</div>
<span>3</span> <script>
<span>4</span><span>var</span> title=$("<span>苹果</span>"<span>);
</span><span>5</span> $("div").append(title);<span>//</span><span>将title追加到div标签内容的后面</span><span>6</span> $("div").before(title);<span>//</span><span>将title追加到div标签之前与div标签属于同一层次</span><span>7</span> $("div").prepend(title);<span>//</span><span>将title追加到div标签内容之前</span><span>8</span> $("div").after(title);<span>//</span><span>将title追加到div标签之后与div标签属于同一层次</span><span>9</span> </script>

4.如何在DOM树中替换指定元素?

<span>1</span> <script type="text/javascript" src="jquery-1.4.2.js"</script>
<span>2</span> <div>水果</div>
<span>3</span> <script>
<span>4</span><span>var</span> title=$("<span>苹果</span>"<span>);
</span><span>5</span> $("div"<span>).replaceWith(title);
</span><span>6</span> </script>

  5.将一张图片以淡出的效果消失在页面中:

<span>1</span> <script type="text/javascript" src="jquery-1.4.2.js"></script>
<span>2</span> <img src="color.jpg">
<span>3</span> <script>
<span>4</span> $("img".click(<span>function</span><span>(){
</span><span>5</span>     $(<span>this</span>).fadeOut("slow"<span>);
</span><span>6</span><span>});
</span><span>7</span> </script>

  6.制作一个按钮,当按钮被单击时以卷帘效果消失:

<span>1</span> <script type="text/javascript" src="jquery-1.4.2.js"></script>
<span>2</span> <input type="button" value="按钮"><script>
<span>3</span> $("input").click(d=<span>function</span><span>(){
</span><span>4</span>         $(<span>this</span>).slideUp("slow"<span>);
</span><span>5</span><span>});
</span><span>6</span> </script>

  7.照片轮换效果:

<span> 1</span> <script type="text/javascript" src="jquery-1.4.2.js"></script>
<span> 2</span> <style>
<span> 3</span> ul{list-<span>style:none;width:350px;height:200px;position:absolute}
</span><span> 4</span><span>li{position:ansolute}
</span><span> 5</span> </style>
<span> 6</span> <div>
<span> 7</span> <ul>
<span> 8</span> <li><img ssrc="1.jpg" width=350px height=200px></li>
<span> 9</span> <li><img ssrc="2.jpg" width=350px height=200px></li>
<span>10</span> <li><img ssrc="3.jpg" width=350px height=200px></li>
<span>11</span> <li><img ssrc="4.jpg" width=350px height=200px></li>
<span>12</span> </ul>
<span>13</span> </div>
<span>14</span> <script>
<span>15</span> $(<span>function</span><span>(){
</span><span>16</span>     $(."change ul li:not(:first)"<span>).hide();
</span><span>17</span>     setInterval(<span>function</span><span>(){
</span><span>18</span><span>if</span>($."change ul li:last").is(":visible"<span>)){
</span><span>19</span>             $(."change ul li:first").fadeIn("slow"<span>);
</span><span>20</span>             $(."change ul li:last"<span>).hide();
</span><span>21</span>     }<span>else</span><span>{
</span><span>22</span>             $(."change ul li:visible").next().fadeIn("slow"<span>);
</span><span>23</span><span>    }
</span><span>24</span>   },1000<span>);
</span><span>25</span><span>});
</span><span>26</span> </script>   

鉴于最近要准备各种期末考和大作业,发博时间明显减少,劳烦多多理解啊!本篇都是利用零碎时间编辑的,现在大功告成还是挺满足啦,若您觉得有帮助,可以随手点个赞。

以上就介绍了PHP求职宝典系列——PHP Web 编程篇,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。