read file & show a part of it

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

johnmayer860
New php-forum User
New php-forum User
Posts: 3
Joined: Sun Oct 07, 2012 5:51 am

read file & show a part of it

Postby johnmayer860 » Sun Oct 07, 2012 6:20 am

hi to all
i have a question.
i have many files (page.php , index.php , module.php , ...) and at the top of them i wrote that file information.
for example :
/*
fileName : page
Description : description of file
Version : 1.0
*/

i want to read this part of file and store in variables ($name = page,$desc = description of file, $ver = 1.0) and use these vars in my codes.
this is like wordpress theme information that get that info s from style.css file.
now, how i can read these lines? what shall i do?
pls help me, thanks :help:

us2rn4m2
New php-forum User
New php-forum User
Posts: 17
Joined: Thu Aug 09, 2012 1:28 pm

Re: read file & show a part of it

Postby us2rn4m2 » Mon Oct 08, 2012 9:02 am

Hi,

Code: Select all

/**
* fileName : page
* Description : description of file
* Version : 1.0
*/
   class Example {}

   $rc = new ReflectionClass('Example');
   var_dump($rc->getDocComment());


Result:
/**

* fileName : page

* Description : description of file

* Version : 1.0

*/

http://www.php.net/manual/en/book.reflection.php


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest