Friday, March 20, 2020

How to Use $_SERVER in PHP

How to Use $_SERVER in PHP $_SERVER is one of the PHP global variables- termed Superglobals- which contain information about server and execution environments. These are pre-defined variables so they are always accessible from any class, function or file. The entries here are recognized by web servers, but there is no guarantee that each web server recognizes every Superglobal. These three PHP $_SERVER arrays all behave in similar ways- they return information about the file in use. When exposed to different scenarios, in some cases they behave differently. These examples may help you decide which is best for what you need. A full list of $_SERVER arrays is available at the PHP website. $_SERVER[PHP_SELF] PHP_SELF is the name of the currently executing script. yoursite.com/example/ /example/index.phpyoursite.com/example/index.php   /example/index.phpyoursite.com/example/index.php?atest   /example/index.phpyoursite.com/example/index.php/dir/test   /dir/test When you use $_SERVER[’PHP_SELF’], it returns the file name /example/index.php both with and without the file name typed in the URL. When variables are appended at the end, they were truncated and again /example/index.php was returned. The only version that produced a different result has directories appended after the file name. In that case, it returned those directories. $_SERVER[REQUEST_URI] REQUEST_URI refers to the URI given to access a page. yoursite.com/example/   /yoursite.com/example/index.php   /example/index.phpyoursite.com/example/index.php?atest   /example/index.php?atestyoursite.com/example/index.php/dir/test   /example/index.php/dir/test All of these examples returned exactly what was entered for the URL. It returned a plain /, the file name, the variables, and the appended directories, all just as they were entered. $_SERVER[SCRIPT_NAME] SCRIPT_NAME is the current scripts path. This comes in handy for pages that need to point to themselves. yoursite.com/example/   /example/index.phpyoursite.com/example/index.php   /example/index.phpyoursite.com/example/index.php?atest   /example/index.phpyoursite.com/example/index.php/dir/test   /example/index.php All cases here returned only the file name /example/index.php regardless of whether it was typed, not typed, or anything was appended to it.

Tuesday, March 3, 2020

Increasing, Decreasing, and Constant Returns to Scale

Increasing, Decreasing, and Constant Returns to Scale The term returns to scale  refers to how well a business or company is producing its products. It tries to pinpoint increased production in relation to factors that contribute to production over a period of time. Most production functions include both labor and capital as factors. How can you tell if a function is increasing returns to scale, decreasing returns to scale, or having no effect on returns to scale? The three definitions below explain what happens when you increase all production inputs by a multiplier. Multipliers For illustrative purposes, well call the multiplier m. Suppose our inputs are capital and labor, and we double each of these (m 2). We want to know if our output will more than double, less than double, or exactly double. This leads to the following definitions: Increasing Returns to Scale: When our inputs are increased by m, our output increases by more than m.Constant Returns to Scale: When our inputs are increased by m, our output increases by exactly m.Decreasing Returns to Scale: When our inputs are increased by m, our output increases by less than m. The multiplier must always be positive and greater than one because our goal is to look at what happens when we increase production. An m of 1.1 indicates that weve increased our inputs by 0.10 or 10 percent. An m of 3 indicates that weve tripled the inputs. Three Examples of Economic Scale Now lets look at a few production functions and see if we have increasing, decreasing, or constant returns to scale. Some textbooks use Q for quantity in the production function, and others use Y for output. These differences dont change the analysis, so use whichever your professor requires. Q 2K 3L: To determine the returns to scale, we will begin by increasing both K and L by m. Then we will create a new production function Q’. We will compare Q’ to Q.Q’ 2(K*m) 3(L*m) 2*K*m 3*L*m m(2*K 3*L) m*QAfter factoring, we can replace (2*K 3*L) with Q, as we were given that from the start. Since Q’ m*Q we note that by increasing all of our inputs by the multiplier m weve increased production by exactly m. As a result, we have constant returns to scale.Q.5KL: Again, we increase both K and L by m and create a new production function. Q’ .5(K*m)*(L*m) .5*K*L*m2 Q * m2Since m 1, then m2 m. Our new production has increased by more than m, so we have increasing returns to scale.QK0.3L0.2: Again, we increase both K and L by m and create a new production function. Q’ (K*m)0.3(L*m)0.2 K0.3L0.2m0.5 Q* m0.5Because m 1, then m0.5 m, our new production has increased by less than m, so we have decreasing returns to scale. Although there are other ways to determine  whether a production function is increasing returns to scale, decreasing returns to scale, or generating constant returns to scale, this way is the fastest and easiest. By using the m multiplier and simple algebra, we can quickly solve economic scale questions. Remember that even though people often think about returns to scale and economies of scale as interchangeable, they are different. Returns to scale only consider production efficiency, while economies of scale explicitly consider cost.