Though the original post is now several months old, I'll show a high-level basic example use of each, below, for informational reference for those that might not be familiar with the syntax/usage...
The %s is used with certain print-format functions, such as
sprintf().
- Know that there are other "format specifiers" available, not only %s.
- There are also other functions that use the specifiers in a similar manner. Refer to the "See Also" section in the above sprintf link.
The %1 [%2, etc] is used with variable function argument/parameter counts.
=========
An example with the [function argument/parameter] numbers %1, %2, etc:
From en_GB/strings.txt:
- Code: Select all
...
$TLS_audit_login_succeeded = "Login for '{%1}' from '{%2}' succeeded";
...
...then in file login.php, we can find:
- Code: Select all
// Login successful, redirect to destination
logAuditEvent(TLS("audit_login_succeeded",$argsObj->login,
$_SERVER['REMOTE_ADDR']),"LOGIN",$_SESSION['currentUser']->dbID,"users");
...the portion of interest is the first parameter to logAuditEvent() which is a call to TLS().
TLS is passed a string reference along with the login and IP address. The login ultimately replaces %1 and the IP address replaces the %2 to complete the string.
The TLS() definition is in file: /lib/functions/metastring.class.php. Look there to see how the arguments are gathered.
===========
Now a %s example:
From en_GB/strings.txt:
- Code: Select all
...
$TLS_importViaAPI = "Import via API (%s)";
...
...we can find that string being used in file: /lib/requirements/reqSpecView.php
- Code: Select all
...
$gui->btn_import_req_spec = sprintf(lang_get('importViaAPI'),$reqMgrSystem['reqmgrsystem_name']);
...
...so to the sprintf, the first function argument is the string [which contains the %s format], and the second function argument is what replaces the %s to complete the string.
HTH.