Viewed   65 times

I am new to PHP. In the path of learning PHP language, I notice that, some website would this kind of URL:

My questions:

  1. What is the "?" symbol used for?

  2. If I were develop a php website, must I use it in my URL? For example, after a user(roa3) successful logged in, I will redirect to "" instead of ""

  3. What are the advantages and disadvantages of using it?



Good questions, briefly,

  1. "?" stands for the start of querying string which contains the data to be passed to the server. in this case you are passing user=roa3 to profile.php page. You can get the data by using $_GET['user'] within profile.php. querystring is one of the methods to send data to the server from client agent. The other one places the data in HTTP body and POST to the server, you don't see the HTTP POST?data directly from browser.

  2. querystring can be edited by user and it is visible to the public. If is intended to be public then it is fine, otherwise you may want to use session to get current user's context.

  3. it is a flexible way to pass data to the server, but it is visible and editable to the users, for some sensitive data, at least produce some kind of hash before attaching it to the querystring, this prevents users to edit it or understanding the meaning of it. However this doesn't prevent a decent hacker to do something wrong about your website. Different browsers support different max length of URL, the lengthy URL is made up by those querystring parameters. If you want to send large amount of data, place the data in the HTTP body and POST to the server.

Saturday, October 29, 2022

The weird characters in the values passed in the URL should be escaped, using urlencode().

For example, the following portion of code :

echo urlencode('dsf13f3343f23/23=');

would give you :


Which works fine, as an URL parameter.

And if you want to build aquery string with several parameters, take a look at the http_build_query() function.

For example :

echo http_build_query(array(
    'id' => 'dsf13f3343f23/23=',
    'a' => 'plop',
    'b' => '$^@test', 

will give you :


This function deals with escaping and concatenating the parameters itself ;-)

Friday, October 14, 2022

::, the scope resolution operator, is used for referencing static members and constants of a class. It is also used to reference a superclass's constructor. Here is some code illustrating several different uses of the scope resolution operator:

class A {
    const BAR = 1;
    public static $foo = 2;
    private $silly;

    public function __construct() {
         $this->silly = self::BAR;

class B extends A {
    public function __construct() {

    public static function getStuff() {
         return 'this is tiring stuff.';

echo A::BAR;
echo A::$foo;
echo B::getStuff();

A little trivia: The scope resolution operator is also called "paamayim nekudotayim", which means "two dots twice" in hebrew.

& in the context of your example isn't doing anything useful if you are using php 5 or greater and should be removed. In php 4, this used to be necessary in order to make sure a copy of the returned object wasn't being used. In php 5 object copies are not created unless clone is called. And so & is not needed. There is still one case where & is still useful in php 5: When you are iterating over the elements of an array and modifying the values, you must use the & operator to affect the elements of the array.

Friday, August 19, 2022

The "domainNameSuffix" is called a top level domain (tld for short), and there is no easy way to extract it.

Every country has it's own tld, and some countries have opted to further subdivide their tld. And since the number of subdomains ( is also variable, there is no easy "one-regexp-fits-all".

As mentioned, you need a list. Fortunately for you there are lists publicly available:

Sunday, November 13, 2022
  • Single $ for reserved, public identifiers
  • Double $$ for reserved private identifiers

To quote the docs:

$ Prefix Naming Convention


If you inspect a Scope, you may also notice some properties that begin with $$. These properties are considered private, and should not be accessed or modified.

Saturday, September 17, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :