• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

what does this statement mean in php?

Can someone let me know what this translates to ?

$mediaFolder = dirname(__FILE__).'/media';

$wavFilename = sprintf('%s/u%d_m%d.wav', $mediaFolder, (int)$recordingRow['uniqueid'], (int)$recordingRow['msgnum']);

Thank you,
A
0
aej1973
Asked:
aej1973
  • 7
  • 3
  • 3
  • +1
3 Solutions
 
mankowitzCommented:
ok,

__FILE__ is the currently running script (i.e. /usr/scott/script.php)
dirname() gets the directory part of the file,

so $mediaFolder contains the subdirectory "media" off of the the folder where the script is running from.

$wavFilename is a filename in the above folder named

uXXXd_mYYYY.wav

where XXX and YYY are numbers from a database referring to uniqueid and msgnum
0
 
aej1973Author Commented:
how about this...?


sprintf('%s/u%d_m%d.wav', $mediaFolder, (int)$recordingRow['uniqueid'], (int)$recordingRow['msgnum']);
0
 
aej1973Author Commented:
I mean... '%s/u%d_m%d
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Cornelia YoderArtistCommented:
http://php.net/manual/en/function.sprintf.php

The % codes are part of the formatting that sprintf() does.
0
 
aej1973Author Commented:
ok, what does the /u  mean? That is the part that is confusing me, and also %d_m. Thank you.

A
0
 
Ray PaseurCommented:
I think that /u might mean /u.  Why not try using the formatting codes with some predictable data so you can test the effects?  You can use var_dump() to print out the resulting strings.  Then you will not only know the answer, you will also have a teaching example you can store in your samples library for future use!
0
 
aej1973Author Commented:
Thanks.
0
 
Cornelia YoderArtistCommented:
There are three parameters after the formatting spec.

It appears that one is a file name and two are integers.

The formatting says

1.  format the file name followed by /u
2.  format the first number as an integer followed by _m
3.  format the second num as an integer followed by .wav

So the result would be something like filename/u3_m7.wav
0
 
Cornelia YoderArtistCommented:
ummmm, why did you give a grade of B when people were still answering you?
0
 
Ray PaseurCommented:
Please see the grading guidelines here:
http://www.experts-exchange.com/help/viewHelpPage.jsp?helpPageID=26

I'd like to call your attention to these expectations:
A should be the default grade awarded unless the answer is deficient.
And to this requirement:
A B grade means the solution given lacked some information or required you to do a good amount of extra work to resolve the problem. When closing the question, the asker should explain why a B grade was awarded.
So what was wrong with the answers and why did you not follow up before giving the bad grade?
0
 
aej1973Author Commented:
Ray,

you are right I have made a mistake in my grading, how can I go back and correct this? I apologize for this error.

Regards,
A
0
 
Ray PaseurCommented:
You can use the "Request Attention" button to ask a moderator for assistance.  The mods can change the grade or re-open the question if you still need assistance.

Thanks and regards, ~Ray
0
 
aej1973Author Commented:
Thanks Ray, I have submitted the request.
0
 
aej1973Author Commented:
Thank you.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now