%1 is a placeholder for the first argument in many programming languages. It can also be used to represent the current directory, or as an input prompt when setting interactive commands.
In programming, % means to substitute the text in brackets for what is inside it. So when you see “%s” in a program and put your cursor after it, this would mean that whatever follows (the string) should be replaced by “%s.” So in most cases, “%1” can be understood as the first argument.
Table of Contents
Example in a batch file
When used in a script, or command line, %1 is a variable that represents data from the input queue. For example, in a batch file, %1 can print what has been typed.
example.bat file content:
@echo off
echo Hello %1
pause
If we run the command example.bat TLDevTech
, it will print out “Hello TLDevTech”.
Example in PHP
In a PHP format function, %1 stands for the first argument.
$format = '%2$s is %1$d years old';
echo sprintf($format, 20, 'John');
//output: John is 20 years old.