大家好我想用PowerShell从用户ID中获取数字
我们使用的格式是名字的第一个字母,姓氏和studentid的前四个字母,所以名为John Smith且ID为#123456的学生将是jsmit123456,如果用户少于4个字母,我将得到的问题他们的名字.所以使用子字符串会给那些id的错误
我尝试了select-string,-match,trim,trimstart,trimend
到目前为止,这是我的代码
$name = Get-ADUser -SearchBase "OU=A,DC=B,DC=C,DC=edu"
-Filter {Created -ge $checktime}
|Select-Object SAMAccountName
foreach($object in $name){
$object
$studentid = $object.SAMAccountName.Substring(5,6)
$studentid
}
Run Code Online (Sandbox Code Playgroud) 我有一个奇怪的问题。我要求用户输入 1 到 15 之间的数字。然后我会要求用户使用递归或 for 循环来获取该数字的阶乘值。当他们回答该问题时,输入的值将变为 0。如果我出于测试目的删除该问题,则该值将保留用户输入的值。
#include <stdio.h>
int recursive(int);
int nonRecursive(int);
int main()
{
/* Variables */
int numberSelected, returnedValue;
char answer;
do
{
/* Request a number between 1 and 15 */
printf("Please enter a number between 1 and 15: ");
scanf("%d", &numberSelected);
printf("%d\n", numberSelected); /* This prints out the user's number */
}while(numberSelected < 1 || numberSelected > 15); /* Loops if the value is not between 1 and 15 */
/* Ask user if …Run Code Online (Sandbox Code Playgroud) 我试图让我的php验证用户已经输入了所需的信息.
我想确保此人已在其中输入姓名和电子邮件.我放的时候:
if(empty($name){
blah blah
}
Run Code Online (Sandbox Code Playgroud)
它给出了错误,但它仍然处理电子邮件.当我把:
if(empty($name){
blah blah
}else{
blah blah
}
Run Code Online (Sandbox Code Playgroud)
我收到一个错误说:Parse error: syntax error, unexpected '}' in /home/dreamcpu/public_html/insert.php on line 34.
这是我的PHP:
<?php
$con = mysql_connect("localhost","blah","blah");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$today = date("F j, Y, g:i a");
mysql_select_db("dreamcpu_contact_info", $con);
$sql="INSERT INTO contact_us (name, email,phone_number,job_request,DateRequested)
VALUES
('$_POST[name]','$_POST[email]','$_POST[phone_number]','$_POST[job_requested]','$today')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error(). "Actual query: " . $sql);
}
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone_number']; …Run Code Online (Sandbox Code Playgroud)