Can you call a function inside an echo statement in PHP?
Of course it is possible to call a PHP-function inside an echo statement. The function will be executed and returns a value. This value then is used in the echo statement.
For example:
echo "Ferengi-Rule #1: ", ferengi_rule(1), "\n";
echo "Random: ", ferengi_rule(0), "\n";
function ferengi_rule($number)
{
$rules = array(
1 => "Once you have their money, never give it back.",
2 => "You can't cheat an honest customer, but it never hurts to try.",
3 => "Never buy anything for more than is absolutely necessary.",
4 => "Sex and profit are the two things that never last long enough."
// ...
);
if( isset($rules[$number]) )
{
return $rules[$number];
}
else
{
return array_rand($rules);
}
}
How do you protect your PHP database settings file?
you can put the connection file 1 level above your website's directory, and use random names, like 2134j12h5kh35.php
but really, if it's extension is .php, and in the unlikely event that someone knows where it is, the server will process it anyway and unless you echo your connection details for some strange reason, nothing will be displayed.
How do you convert a pdf file in PHP?
There are a few different PHP pdf generators out there. PDFLIB and FPDF. You need to purchase a license for PDFLIB but FDP is free.
What is a PHP function that can sort arrays by other arrays?
You cannot sort arrays by other arrays; that wouldn't make sense, anyway.
PHP is a programming language that is used to generate dynamic web pages based on user requests and other data that changes such as store inventory, current news, or time of day.
How do you block a users account if they enter a wrong password 3 times in PHP?
use session :o
in your form processing php page. add 1 to a session variable. as soon as it reaches 3, you block the account with the username that he enters.
I don't know what your website is like so I can't help more :x
A PHP file is a text file containing code to be run on a webserver by a program called php. It's the most used dynamic page script engine as it is free and open source.
Use the fopen() function to open files in PHP. The first parameter of this function is the file to be opened and the second parameter specifies in which mode the file should be opened
What are the limitations of PHP?
Everything has limitations or disadvantages and PHP is no exception. The following are the limitations of PHP (so be WARNED !!) # PHP is NOT 100 % pure Object Oriented scripting language. But in near future PHP may support 100% object oriented scripting (PHP may imitate most of the syntax of Java language). PHP already imitates some features of Java language. (In future PHP language will imitate most features of Java language and Java programmers will love PHP. And PHP will have java keywords like class, extends, interface, implements, public, protected, private etc..). # PHP will NOT give the performance of "C" or "C++" language. Because it is scripting language and is interpreted it will be a bit slower than the optimized "C++" programs. For top performance, you should use "C++" and fast-CGI with database/webserver connection pooling and use C++ compiler optimizer "-O3" options. Zend optimizer in PHP 4 will speed up the performance of PHP and bring it very close to optimized "C" code . # But note a point that PHP was designed for very Rapid Web-Application Development tool. If it takes about 3 months to code a web application in C++, then using PHP you can develop the same web application in just 4 days!! And with zend optimizer, the speed of execution of PHP will be very close to that of equivalent C++ program!! Hence, there is really no advantage in using C/C++ for web development. PHP itself is written in 100% "C" language. On the other hand, PHP has lot of advantages and it's advantages outweigh it's limitations - # You can very rapidly develop web applications in PHP as compile and link is eliminated in PHP scripting language. # PHP applications are very stable and do not depend on the browser technologies unlike Javascript applications which depend on browsers. PHP will give you the freedom to select any server platform. The browser does not know that the HTML page is generated by PHP !! # PHP has excellent database conectivity to all SQL database servers. # PHP has partial support for Object oriented features # PHP has C++, Perl, Javascript like syntax features and has programs like 'ptags/ctags' to navigate the source code # PHP has Zend optimizer which speeds up the performance # PHP runs on all unixes, linux, Windows 95/NT/2000 and is more powerful than ASP, JSP and others. # PHP has a very large user base and developer base.
Ref:http://www.linuxdocs.org/HOWTOs/PHP-HOWTO-14.html
What are the applications of PHP?
The Main purposes are:
and some others
To learn PHP it is best to read a few tutorials and then start trying out the things you read about.
For instance, make a program that does some calculations and then prints the result on the screen.
A good tutorial to start with can be found on: http://w3schools.com/php/default.asp or http://www.geekatude.com/PHP or http://php.net or http://www.phpmysqlbrain.com
You can install the things in your local system , and then by referring the above websites try to write codes and see the results.
Is PHP better on Windows or Linux?
PHP with Linux is completely different, since everything is free (Linux, Apache, Mysql, FileZila, PHP, etc.). Linux is also way more stable for production use, since it's regularly updated (at least once a months, for certain distribution). Remember, the Internet runs on Linux, mostly CentOS and RedHat.However, windows is way more compatible with everyday applications. The best would be to have a development computer running Linux (buy an old, use computer, install Linux on it), and have an everyday Windows computer.
1) Parents Helping Parents
2) Prepaid health plan
3) Abbreviation for the Philippine Peso or some sort of skill
4) The programming language for the web it stands for Personal Home Page (PHP)
How do you include an ampersand in a PHP GET variable?
Use hex codepoints (with percent-signs) to force special characters in a URL:
http://www.example.com/foo.php?bar=%26
<?php
var_dump($_GET['bar']) // &
?>
http://www.example.com/foo.php?%26=bar
<?php
var_dump($_GET['&']) // bar
?>
PHP: Hypertext Preprocessor is the full name of PHP. It originally stood for Personal Home Page. This was changed in 1997 with the release of PHP 3.
Whats the use of using ampersand in PHP?
The ampersand causes two variables to share (point to) the same address in memory. For example:
<php
$first = "first";
$second = &$first;
$second = "third";
echo "$first-$second"; // third-third
?>
See the related link for an official, more detailed expanation.
With echo you can send a string of text, or the return of a function or variable (true, false, null etc.) to the browser of the user.
For example:
$var = 'Hello world!';
echo $var;
?>
This will return "Hello world!" to the user.
It is one of the commands to print or show something on user screen.
In early versions, PHP used to stand for Personal Home Page.
It was renamed to 'PHP: Hypertext Preprocessor'.
The expanded form conatins the acronym itself, therefore it is a recursive acronym.
What are the advantages and disadvantages of PHP?
Advantages
It has both procedure programming language and OOP (object oriented programming) language features. This means that the programmers from different programming language backgrounds can pick up this language within a short period of time. Most similar to C & C++ language syntax.
Open source: It is developed and maintained by a large group of developers. This will help in creating a support community and abundant extension libraries.
Speed: It is relatively fast, since it uses not much system resources.
Easy to use: It uses a C like syntax, so for those who are familiar with C, it’s very easy for them to pick up and easy to create website scripts.
Stable: Since it is maintained by many developers, bugs are rather found and fixed quickly, making it a stable software.
Powerful library support: You can easily find functional modules you need such a PDF, graph etc.
Built in database connection modules: You can connect to databases easily using PHP, since many websites are data/ content driven, so we will use database frequently, this will largely reduce the development time of web apps.
It can be run on many platforms, including Windows, Linux and Mac. therefore it’s easy for users to find hosting service providers.
MySQL is used with PHP as back end tool. Thee popular online database can be interfaced very well with PHP. So it’s been the excellent choice for webmasters. It has powerful output buffering. It can internally rearrange the buffer so that the headers comes before the content. It is dynamic and works in combination with HTML to display dynamic elements on the page.
It can be used with a large number of relational database management systems, runs on all of the web browsers (example: Apache, personal web server, Microsoft IIS, Netscape, iPlanet) and all databases (example: MySQL, dBase, IBM DB2, ODBC, PostgreSQL, Inter Base, Front Base, SQLite). PHP5 is fully object oriented language can be hosted nearly everywhere. Its documentation is excellent. PHP has a selection of decent CMS’s such as Drupal, Expression Engine and WordPress.
PHP runs in separate isolated processes within Apache so it is very difficult for anyone process to bring down the entire web browser. If anything goes wrong, there is minimal effect because PHP’s state is completely reset at the beginning of the each request. This ends up being more reliable than systems that use long-lived processes, that handle many requests. It’s completely free and no need to pay any fees. It is highly flexible and use it’s own memory space.
Community Support: A huge advantage the technology has is its community. If you are looking for a particular script, chances are another user has already created something similar. Check within the community for availability. Likewise, if you have created a function that other’s might enjoy, be sure to post the code for others.
Security: It offers security that can prevent malicious attacks. This can be adjusted for example in the .ini file.
Talent Availability: You can hire programmers with this technology skill more easily than any other language programmers since so many people know the language.
Bright Future: Although PHP is already well established, its future prospects are infinite. The keynote is that PHP is loosely typed. This makes simple scripts much faster to develop. One has to devote much less energy towards design.
Disadvantages
This comes from the ample language features. Some libraries written by a programmer from a procedure programming language may be difficult for programmers with an OOP background to maintain.
Security: Since it is open sourced, all people can see the source code. If there are bugs in the source code, it can be used by people to explore the weakness of it.
Not suitable of large applications: It will be difficult to use it for programming huge applications. Since the programming language is not highly modular, huge applications created out of the programming language will be difficult to maintain.
Weak type: Implicit conversion may surprise unwary programmers and lead to unexpected bugs. Confusion between arrays and hash tables. This is slow and could be faster. There are often a few ways to accomplish a task. It is not strongly typed. It is interpreted and uses curly braces.
Poor Error Handling Method: The framework has a bad error handling method. It is not a proper solution for the developers. Therefore, as a qualified PHP developer, you will have to overcome it.
PHP is unable to handle large number of apps: The technology is helpless to support a bunch of apps. It is highly tough to manage because, it is not competent modular. It already imitates the features of Java language.
It will not give the performance of, for example, “C” or “C++” languages. Because it is a scripting language and is interpreted it will be a bit slower than the optimized “C++” programs.
Which is the best free PHP editor?
There is no best software for anything. There is something that is good for you. If you want smth complex and extremely powerful go for Zend Studio. If smth free and handy go for Notepad++.
Kansas manufactures a number of products including cotton, parts for airplanes, and newspapers. They also produce railroad equipment and food for animals.
How do you get all the files from the directory in PHP?
To list all the files in a directory you would use the following: $handle = opendir('/path/to/folder');
while(($file = readdir($handle)) !== false){
// do things with files
// you will want to filter out things like ., .., and .htaccess
echo $file;
}
Also, to return a list of all the files in a directory, especially with wildcards, use something such as:
$file_array = glob("*"); $files = implode("\n", $file_array);
echo $files;
will give you a list of all the files directly.
What are the POST and GET methods in PHP?
$_POST and $_GET are both PHP functions used to extract input from HTML forms. However, the difference is that $_POST keeps the extracted variables hidden from users, whereas $_GET does not. Because of this, there is a major difference between the two functions in terms of security.
Why would you use $_GET at all, then? Because some websites have large databases full of information for the user. For example, say you were shopping online, and you go to buy 2 pairs of pants (item #125). The URL that you are sent to might look like this:
catalog.php?item=125&quantity=2
As you can see, the variables obtained through $_GET are visible to the user.
The POST method has possibility of much volume data sending (usually by the server settings limited) and it may be used unless it represents benefits in comparing GET method. A lot of browser can not correctly bookmark pages which are displayed after HTTP POST method, because the submitted data is displayed in the address bar.
When you need the query string, which is get by GET method using (ineffective by it's limits), you will try to use POST method for your forms. You can use POST method if you submit the important information which shouldn't be displayed in the address bar.