9

Read the content of the Php file

 2 years ago
source link: https://www.codesd.com/item/read-the-content-of-the-php-file.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Read the content of the Php file

advertisements

I am trying to read the upper most comments of a style sheet using php, what i want is on/ce the comments get over php should stop reading that file let me show you my code

$handle = fopen($filename,"r");
        if ($handle)
        {
            while (($file = fgets($handle, 4096)) !== false)
            {
                if($file != '*/')
                {
                echo $buffer.'<br />';
                }
                else
                {
                    break;
                }
            }
        }

What i am trying to do is reading the file line by line and the movement my line is equal to the sign of ending css comments it should not run that while statement but that is not working right now


how about adding trim, to deal with whitespace & the line ending "\r\n"s

$handle = fopen($filename,"r");
        if ($handle)
        {
            while (($file = fgets($handle, 4096)) !== false)
            {
                if (trim($file) == '*/') {
                    break;
                }
                echo $buffer.'<br />';
            }
        }

Related Articles

The AJAX variable does not read the PHP file?

This is my javascript that holds the function to save the file. function saveMap() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new Acti

Read the .php file without applying the HTML and PHP tags in the result

I need to read a .php file as plain text. Text in main script: <?php $data = file_get_contents('file2read.php'); ?> <pre> <?php echo $data; > </pre> For example, I have this in file2read.php: <tr> <td><?php> e(enl

Reading the php file and mysql search

I have two columns in a table (MYSQL database) One column contains an alias and the other contains the real name Coln1:The_Spiderman coln2:-Peter,J,Parker ** Note: Coln 1 is actually the name of the file. So, it cannot contain special characters. How

how to read the php file version of the file?

is there a way (a php function) to get the version 1.0.0.0 from a file? /** * @author softplaxa * @copyright 2011 Company * @version 1.0.0.0 */ thanks in advance!No, there is not a native php function that will extract the version 1.0.0.0 you listed,

Moves all text in the .php file to Array

I need to implement a multi-language system on my website. But, I have so many files with text in them and I need to put all of this text in a array like: $lang['text1'] = "Example"; The biggest problem is because I have so many files, moving al

How to get html generated content from a php file instead of including the file

I want to make a cms which generates html pages and creates files to store each page. Ideally i need something like that: <?php $file1 = get_produced_html_from('mainPage.php'); /* write the file to a directory*/ $file2 = get_produced_html_from('Produ

Piping the contents of the PHP file to the PHP command in CLI

My question relate to the use of PHP in CLI. I don't know why the piping of the content of a PHP file to the PHP command works: cat file.php | php like in the installation of Composer Composer Installation: curl -sS https://getcomposer.org/installer

Reading the last file created php

I know how to read files in PHP but I want to read the latest file that has been created in a specific folder. I have a html button pointing to read.php read.php reads the folder c:\file\ and reads the latest file that is created in that folder. I co

Get HTML content from the php file, after being processed

I want to get the contents of a php file in HTML. I am using it as a HTML email template but it needs to be populated with dynamic data from my database. I tried file_get_contents('/emails/orderconfirm.php'); But all that does is return the php code

include the contents of the php file

I want to include the content from a php file into another php file. (It's in a wordpress site) Include or require won't work because it's just including the file, I need the content itself. file_get_contents is also not working because it just displ

php reads the text file and compares it with the user input

I have a text file called login.txt and I want to compare the id and password with the user's input with the one saved in the text file. I'm stuck with the php file. Any help will be appreciated. login.txt Brian,brianpass\n Adam,adampass\n Bob,bobpas

reading the csv file in php

I want to read a csv file line by line. i have written code but it give output in encrypted manner . my code is $row = 1; $handle = fopen($_FILES['csv']['tmp_name'], "r"); while (($data = fgetcsv($handle, 1000,",")) != FALSE) { $num =

Draw IMAGE in the PHP file

I have a PHP file and an image in the same directory. How could I get the PHP file to set it's headers as jpeg and "pull" the image into it. So if I went to file.php it would show the image. If I rewrite file.php to file_created.jpg and it needs

Sending javascript data to the php file

I have this function that gets text from a php file on the server and plonks it into an HTML page. What changes do I need to make to it to SEND data (just a couple of javascript variables) to the php file rather than read from it ? Hoping not many !!

Strange string behavior after reading the text file in python

I am reading a text file which I know its 38th line is "Uncalibrated Peaks:", and I know its stored in 38th element of my list. I already check them and there is no indexing problem. I am reading the text file by the following code import os fd

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK