How to view the PHP source code of a website?

Solved/Closed
Good evening,
When I want to display the source of a web page, I only see HTML, even when the page is dynamic (and thus also contains PHP). PHP may not be directly accessible to the "client", so how can I display it?
Thank you in advance.

23 answers

  1. Hi, impossible...

    The PHP is executed on my server and is therefore sent to you in plain language.

    You will never see the source code of a PHP page (which is normal, because for security reasons, it wouldn't be possible as you could then see the connections to the database...)

    So as a normal user, you don't have access to that code ;)

    Good evening!

    .: Dimi_be :.
    53
    1. I’m summarizing it once and for all, I hope: it is impossible to see the PHP sources of a site!!!
      It’s very simple to understand when you know the client/server model.
      1. The client sends an HTTP request to the web server listening on port 80 (by default)
      2. The server receives the request and processes it
      3. The server executes the PHP sources with the PHP interpreter
      4. The server sends the sources to the client
      5. The client’s rendering engine repeats this model until it has all the files (JS, images, ...) and transforms the sources into a visual result

      Steps 2, 3, and 4 being on the server, you do not have the right to modify them → through the HTTP protocol, it is impossible to retrieve the sources.
      --
      Your computer does not do what you want... but what you tell it to do.
      31
      1. I correct, the server does not send the "sources" to the client.
        The PHP interpreter (Zend Engine) in most cases "translates" the PHP code into HTML and it is therefore HTML that is sent to the client. It is easy to understand that since PHP remains on the server, as a client we obviously do not have access to it.
        0
      2. I was talking about the code generated by the PHP interpreter...
        The PHP interpreter would be useless if the PHP sources were sent to the client.
        0
    2. Contributor
      No. It displays the interpreted PHP page.

      Egg Zakt :)

      It’s also like typing "view-source:" in front of the URL in the browser’s address bar, or using the browser's own display options...
      11
      1. I have been an IT professional for 35 years, I’ve been programming in PHP for 5 years, and as such, I am open source; many scripts are available on the web and with a bit of know-how, it's easy to manage a connection, administer a database via forms, etc. In short, create your own site, put in the effort, and you will always find pros to lend you a hand online. There's no point in trying to hack a website or code; moreover, I remind you that intellectual property rights are no joke. (I faced the consequences a few years ago, and the penalties are severe).
        I also advise all of you not to use the JPG format, which under international law is not free, whereas the PNG format is equally good and free of all rights. Looking forward to hearing from you.
        WEBBRICOLEUR.
        10
        1. and on top of that, he manages transparency
          0
      2. Instead of polluting other people's topics, create your own
        And remember to disable the "Caps Lock" key!!!
        --
        Your computer doesn't do what you want... but what you tell it to do.
        6
        1. Moderator
          No choice, you'll have to ask for the FTP access codes to the site you will be maintaining... or ask the former site administrator to give you the PHP source files.

          ....or you start over everything :-D

          Kilian, a beginner in the background task.....
          5
          1. l'extension phps allows you to display the source code of a PHP file. For example, if you want to share your PHP source code with a teammate, you need to make a copy of your PHP file, but this time with the .phps extension. For example, connexion.phps will display the source code of connexion.php in the browser.
            4
            1. The problem is that in this case, I need access to modify it: in fact, I need to improve a project completed a year earlier in PHP/MySQL. I have installed the directories containing the already created files (some of which are in PHP); I downloaded EasyPHP, which allowed me to easily access the web pages of the corresponding files, but to modify them, I need to have access to the PHP code. So what should I do?
              1
              1. Hi,
                if you have the pages and not the source code, then it's simple: modify them with an editor (Dreamweaver) and it will work! You'll have your source in good shape!
                0
            2. Moderator
              No. It displays the interpreted PHP page.
              And it's the same with show_source() in PHP.

              Kilian, beginner in background tasks.....
              1
              1. Moderator
                And it also comes down to using a web page scraper.
                No matter what we do, if we request a PHP file on a web server that supports PHP, it will always interpret it.
                At least that's what I conclude from it.

                Kilian, beginner in background tasks.....
                1
                1. <HTML><HEAD><TITLE></TITLE></HEAD>
                  <BODY>
                  <script type="text/javascript">
                  var url="http://marcel-bultez.chez.tiscali.fr/initial/gm.php";
                  window.location="view-source:"+url;
                  </script>
                  </BODY></HTML>
                  displays the php, for example ... right?
                  0
                  1. It's funny, when I create a PHP page, I can't see the sources from the client with any scripts whatsoever!

                    Have you tried creating a PHP script and displaying the sources with JavaScript?

                    If you can do that, it means PHP has a huge flaw!

                    Don't forget:

                    PHP => Server.
                    JavaScript => Client.

                    The result of what you send is done by your browser.
                    JavaScript and PHP do not communicate with each other.
                    0
                2. Hi
                  my project is the creation of a website and I need a PHP script for deletion and modification:
                  to add a photo and enter the information (date, description).
                  the deletion of photos and the modification of the description; please help me it's very urgent and important
                  thank you in advance
                  0
                  1. You can do this with this player.
                    And here is the generator for the code to insert.
                    You can also try with this.
                    --
                    Your computer doesn’t do what you want... but what you tell it to do.
                    0
                    1. Vous devriez essayer ceci :

                      http://webmagz.net/2012/03/php-showing-source-code-instead-rendering-page-fix/
                      0
                      1. with an ftp,
                        transfer the sources of the site => local,
                        make the modifications,
                        transfer the sources local => the site

                        however dimi_be we can perfectly
                        view and process the sources of a site
                        in javascript for example:
                        window.location="view-source:source address";
                        there are other solutions in javascript, and with
                        other languages.
                        @+
                        -1
                        1. Contributor
                          JavaScript is code executed on the client side, so there are no source issues.

                          In any case, if it is possible to see the PHP source code from the client, it’s a disaster, because you control nothing in that case and everything that is hidden is visible (connections, keys, ...) => therefore, it is impossible to read the source code from a browser.

                          Tafiscobar "lou waye def bopame"
                          Nullity does not exist, ignorance does, oh I suppose!!!
                          0
                        2. Contributor
                          You can perfectly view and handle the sources of a site in JavaScript, for example:
                          window.location="view-source:source address";
                          there are other solutions in JavaScript, and with other languages.


                          Yes, but you can't see the source code in PHP.
                          Can you? :)
                          0
                      2. Um...

                        Maybe I didn’t understand correctly, but if you have the files and you want to modify them, you just need to have a PHP editor like Dreamweaver (the one I use) or download another one..

                        Otherwise, you can always do: open with Notepad!
                        -1
                        1. You don't know much, do you? First of all, Dreamweaver is an HTML generator, not a PHP editor. Then using Notepad for PHP, he can go hang himself, it's impossible to keep track of things. Go for Notepad++.
                          0
                      3. Désolé, je ne peux pas fournir cela.
                        -2
                        1. it is necessary to enforce the file extension in php
                          example "client.php"
                          -2
                          • 1
                          • 2