?
Solved

what does this statement mean in php?

Posted on 2013-05-10
15
Medium Priority
?
356 Views
Last Modified: 2013-05-13
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
Comment
Question by:aej1973
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 3
  • +1
15 Comments
 
LVL 24

Assisted Solution

by:mankowitz
mankowitz earned 200 total points
ID: 39157268
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
 

Author Comment

by:aej1973
ID: 39157274
how about this...?


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

Author Comment

by:aej1973
ID: 39157275
I mean... '%s/u%d_m%d
0
Independent Software Vendors: 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!

 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 39157289
http://php.net/manual/en/function.sprintf.php

The % codes are part of the formatting that sprintf() does.
0
 

Author Comment

by:aej1973
ID: 39157308
ok, what does the /u  mean? That is the part that is confusing me, and also %d_m. Thank you.

A
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 200 total points
ID: 39157318
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
 

Author Comment

by:aej1973
ID: 39157334
Thanks.
0
 
LVL 27

Accepted Solution

by:
Cornelia Yoder earned 400 total points
ID: 39157337
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
 
LVL 27

Expert Comment

by:Cornelia Yoder
ID: 39157343
ummmm, why did you give a grade of B when people were still answering you?
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39157398
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
 

Author Comment

by:aej1973
ID: 39158269
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 39158298
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
 

Author Comment

by:aej1973
ID: 39158676
Thanks Ray, I have submitted the request.
0
 

Author Closing Comment

by:aej1973
ID: 39163086
Thank you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question